Update gthread.py

upgrade gthread worker when behind load balancer
This commit is contained in:
deco 2020-03-11 20:14:30 +08:00 committed by GitHub
parent 8cb2bd2329
commit 3bf93193f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -238,7 +238,7 @@ class ThreadWorker(base.Worker):
(keepalive, conn) = fs.result() (keepalive, conn) = fs.result()
# if the connection should be kept alived add it # if the connection should be kept alived add it
# to the eventloop and record it # to the eventloop and record it
if keepalive: if keepalive and self.alive:
# flag the socket as non blocked # flag the socket as non blocked
conn.sock.setblocking(False) conn.sock.setblocking(False)
@ -307,7 +307,7 @@ class ThreadWorker(base.Worker):
conn.server, self.cfg) conn.server, self.cfg)
environ["wsgi.multithread"] = True environ["wsgi.multithread"] = True
self.nr += 1 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.") self.log.info("Autorestarting worker after current request.")
resp.force_close() resp.force_close()
self.alive = False self.alive = False