mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
improve worker shutdown
This commit is contained in:
parent
fb53047b73
commit
d775b576e8
@ -84,7 +84,6 @@ class ThreadWorker(base.Worker):
|
||||
self.futures = deque()
|
||||
self._keep = deque()
|
||||
|
||||
|
||||
def _wrap_future(self, fs, conn):
|
||||
fs.conn = conn
|
||||
self.futures.append(fs)
|
||||
@ -117,7 +116,6 @@ class ThreadWorker(base.Worker):
|
||||
fs = self.tpool.submit(self.handle, conn)
|
||||
self._wrap_future(fs, conn)
|
||||
|
||||
|
||||
def murder_keepalived(self):
|
||||
now = time.time()
|
||||
while True:
|
||||
@ -178,7 +176,12 @@ class ThreadWorker(base.Worker):
|
||||
futures.wait(self.futures, timeout=self.cfg.graceful_timeout)
|
||||
|
||||
# if we have still fures running, try to close them
|
||||
for fs in self.futures:
|
||||
while True:
|
||||
try:
|
||||
fs = self.futures.popleft()
|
||||
except IndexError:
|
||||
break
|
||||
|
||||
sock = fs.conn.sock
|
||||
|
||||
# the future is not running, cancel it
|
||||
@ -279,7 +282,6 @@ class ThreadWorker(base.Worker):
|
||||
resp.force_close()
|
||||
self.alive = False
|
||||
|
||||
|
||||
if not self.cfg.keepalive:
|
||||
resp.force_close()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user