From 3bf93193f2a76afb7ba4da3161e3be13933869ac Mon Sep 17 00:00:00 2001 From: deco Date: Wed, 11 Mar 2020 20:14:30 +0800 Subject: [PATCH] Update gthread.py upgrade gthread worker when behind load balancer --- gunicorn/workers/gthread.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gunicorn/workers/gthread.py b/gunicorn/workers/gthread.py index 376c3cb76..1f1a00579 100644 --- a/gunicorn/workers/gthread.py +++ b/gunicorn/workers/gthread.py @@ -238,7 +238,7 @@ def finish_request(self, fs): (keepalive, conn) = fs.result() # if the connection should be kept alived add it # to the eventloop and record it - if keepalive: + if keepalive and self.alive: # flag the socket as non blocked conn.sock.setblocking(False) @@ -307,7 +307,7 @@ def handle_request(self, req, conn): conn.server, self.cfg) environ["wsgi.multithread"] = True self.nr += 1 - if self.alive and self.nr >= self.max_requests: + if self.nr >= self.max_requests: self.log.info("Autorestarting worker after current request.") resp.force_close() self.alive = False