From e7781d2c2c669a87532ec6dd5d04490085ef7559 Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Sun, 7 May 2023 18:02:49 +0200 Subject: [PATCH] gthread: consider intial connectino as idle this change consider the connection is iddle when started and remove it from the eventloop if no change appears in the interval. This prevents the connection queued for too much time. --- gunicorn/workers/gthread.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gunicorn/workers/gthread.py b/gunicorn/workers/gthread.py index 877c1d12..a6bceb32 100644 --- a/gunicorn/workers/gthread.py +++ b/gunicorn/workers/gthread.py @@ -122,10 +122,13 @@ class ThreadWorker(base.Worker): sock, client = listener.accept() # initialize the connection object conn = TConn(self.cfg, sock, client, server) + # set timeout to ensure it will not be in the loop too long + conn.set_timeout() + self.nr_conns += 1 - # wait until socket is readable with self._lock: + self._keep.append(conn) self.poller.register(conn.sock, selectors.EVENT_READ, partial(self.on_client_socket_readable, conn)) except EnvironmentError as e: