From ec62d487f76057504384321a3b5d6412e24558f4 Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Sat, 12 Jul 2014 12:43:32 -0700 Subject: [PATCH] Fix major issue with threaded worker keepalive The keepalive queue management is fixed to not pop extra connections incorrectly. Close #816 --- gunicorn/workers/gthread.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gunicorn/workers/gthread.py b/gunicorn/workers/gthread.py index 122d923e..4c3aeed5 100644 --- a/gunicorn/workers/gthread.py +++ b/gunicorn/workers/gthread.py @@ -134,18 +134,17 @@ class ThreadWorker(base.Worker): now = time.time() while True: try: + # remove the connection from the queue conn = self._keep.popleft() except IndexError: break delta = conn.timeout - now if delta > 0: + # add the connection back to the queue self._keep.appendleft(conn) break else: - # remove the connection from the queue - conn = self._keep.popleft() - # remove the socket from the poller self.poller.unregister(conn.sock)