Merge pull request #1967 from skytoup/master

Fix #1965: About gunicorn [CRITICAL] Worker Timeout
This commit is contained in:
Randall Leeds 2023-12-27 16:19:15 -08:00 committed by GitHub
commit b5d78e8bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

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

View File

@ -4,6 +4,7 @@
# See the NOTICE for more information.
import os
import time
import platform
import tempfile
@ -40,10 +41,11 @@ class WorkerTmp(object):
raise
def notify(self):
os.utime(self._tmp.fileno())
new_time = time.monotonic()
os.utime(self._tmp.fileno(), (new_time, new_time))
def last_update(self):
return os.fstat(self._tmp.fileno()).st_ctime
return os.fstat(self._tmp.fileno()).st_mtime
def fileno(self):
return self._tmp.fileno()