Fix #1965: About gunicorn [CRITICAL] Worker Timeout

This commit is contained in:
l 2019-01-23 22:09:08 +08:00
parent 7af6f651c0
commit 54d35d7358
2 changed files with 5 additions and 6 deletions

View File

@ -494,7 +494,7 @@ class Arbiter(object):
workers = list(self.WORKERS.items()) workers = list(self.WORKERS.items())
for (pid, worker) in workers: for (pid, worker) in workers:
try: try:
if time.time() - worker.tmp.last_update() <= self.timeout: if time.monotonic() - worker.tmp.last_update() <= self.timeout:
continue continue
except (OSError, ValueError): except (OSError, ValueError):
continue continue

View File

@ -4,6 +4,7 @@
# See the NOTICE for more information. # See the NOTICE for more information.
import os import os
import time
import platform import platform
import tempfile import tempfile
@ -35,14 +36,12 @@ class WorkerTmp(object):
os.close(fd) os.close(fd)
raise raise
self.spinner = 0
def notify(self): def notify(self):
self.spinner = (self.spinner + 1) % 2 new_time = time.monotonic()
os.fchmod(self._tmp.fileno(), self.spinner) os.utime(self._tmp.name, (new_time, new_time))
def last_update(self): def last_update(self):
return os.fstat(self._tmp.fileno()).st_ctime return os.fstat(self._tmp.fileno()).st_mtime
def fileno(self): def fileno(self):
return self._tmp.fileno() return self._tmp.fileno()