Compare commits

...

9 Commits

Author SHA1 Message Date
Ankush Menat
bb554053bb
Merge branch 'benoitc:master' into master 2025-05-07 22:04:50 +05:30
Ankush Menat
6f9b8a5a7e fix: use OSError instead of deprecated EnvironmentError 2025-05-07 22:03:04 +05:30
Ankush Menat
6b60bcff7e
Revert "gthread: only read sockets when they are readable" (#7)
* Revert "gthread: only read sockets when they are readable"

This reverts commit 0ebb73aa240f0ecffe3e0922d54cfece19f5bfed.

* chore: update readme
2025-05-07 19:38:52 +05:30
Ankush Menat
ca67a87c37
chore: update readme 2025-05-07 19:38:21 +05:30
Ankush Menat
73eae94e8b Revert "gthread: only read sockets when they are readable"
This reverts commit 0ebb73aa240f0ecffe3e0922d54cfece19f5bfed.
2025-05-07 19:28:08 +05:30
Benoit Chesneau
a86ea1e4e6
Merge pull request #3355 from mondwan/patch-1
Fix typo in the settings.rst
2025-03-20 21:19:12 +01:00
Mond WAN
d05b6c5425 Fix typo in the getgrnam
getgrnam is under grp module instead of pwd
2025-03-14 18:01:52 +00:00
Mond WAN
1bc351e794 Revert "Fix typo in the settings.rst"
This reverts commit 02e5f64c76db6d33ffb22448a7f35d7aececf51d.
2025-03-14 18:00:02 +00:00
Mond WAN
02e5f64c76
Fix typo in the settings.rst
getgrnam is under grp module instead of pwd
2025-03-11 11:16:17 +00:00
3 changed files with 12 additions and 18 deletions

View File

@ -5,6 +5,7 @@ This is a fork of gunicorn with the following changes:
1. Request timeout implementation for `gthread` - https://github.com/frappe/gunicorn/pull/1 (upstream doesn't have any, we NEED this.) 1. Request timeout implementation for `gthread` - https://github.com/frappe/gunicorn/pull/1 (upstream doesn't have any, we NEED this.)
2. Higher timeout for `selector` - https://github.com/frappe/gunicorn/pull/2 (This is a small optional performance improvement) 2. Higher timeout for `selector` - https://github.com/frappe/gunicorn/pull/2 (This is a small optional performance improvement)
3. https://github.com/benoitc/gunicorn/pull/2918 is reverted to avoid connection resets while draining or restarting a worker.
Note to anyone upgrading/adding changes: Note to anyone upgrading/adding changes:
- Pull upstream changes - Pull upstream changes

View File

@ -1177,7 +1177,7 @@ class Group(Setting):
Switch worker process to run as this group. Switch worker process to run as this group.
A valid group id (as an integer) or the name of a user that can be A valid group id (as an integer) or the name of a user that can be
retrieved with a call to ``pwd.getgrnam(value)`` or ``None`` to not retrieved with a call to ``grp.getgrnam(value)`` or ``None`` to not
change the worker processes group. change the worker processes group.
""" """

View File

@ -41,15 +41,12 @@ class TConn:
self.timeout = None self.timeout = None
self.parser = None self.parser = None
self.initialized = False
# set the socket to non blocking # set the socket to non blocking
self.sock.setblocking(False) self.sock.setblocking(False)
def init(self): def init(self):
self.initialized = True
self.sock.setblocking(True) self.sock.setblocking(True)
if self.parser is None: if self.parser is None:
# wrap the socket if needed # wrap the socket if needed
if self.cfg.is_ssl: if self.cfg.is_ssl:
@ -130,27 +127,23 @@ class ThreadWorker(base.Worker):
conn = TConn(self.cfg, sock, client, server) conn = TConn(self.cfg, sock, client, server)
self.nr_conns += 1 self.nr_conns += 1
# wait until socket is readable # enqueue the job
with self._lock: self.enqueue_req(conn)
self.poller.register(conn.sock, selectors.EVENT_READ,
partial(self.on_client_socket_readable, conn))
except OSError as e: except OSError as e:
if e.errno not in (errno.EAGAIN, errno.ECONNABORTED, if e.errno not in (errno.EAGAIN, errno.ECONNABORTED,
errno.EWOULDBLOCK): errno.EWOULDBLOCK):
raise raise
def on_client_socket_readable(self, conn, client): def reuse_connection(self, conn, client):
with self._lock: with self._lock:
# unregister the client from the poller # unregister the client from the poller
self.poller.unregister(client) self.poller.unregister(client)
# remove the connection from keepalive
if conn.initialized: try:
# remove the connection from keepalive self._keep.remove(conn)
try: except ValueError:
self._keep.remove(conn) # race condition
except ValueError: return
# race condition
return
# submit the connection to a worker # submit the connection to a worker
self.enqueue_req(conn) self.enqueue_req(conn)
@ -285,7 +278,7 @@ class ThreadWorker(base.Worker):
# add the socket to the event loop # add the socket to the event loop
self.poller.register(conn.sock, selectors.EVENT_READ, self.poller.register(conn.sock, selectors.EVENT_READ,
partial(self.on_client_socket_readable, conn)) partial(self.reuse_connection, conn))
else: else:
self.nr_conns -= 1 self.nr_conns -= 1
conn.close() conn.close()