Skip to content

Commit 54d35d7

Browse files
author
l
committed
Fix #1965: About gunicorn [CRITICAL] Worker Timeout
1 parent 7af6f65 commit 54d35d7

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

gunicorn/arbiter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def murder_workers(self):
494494
workers = list(self.WORKERS.items())
495495
for (pid, worker) in workers:
496496
try:
497-
if time.time() - worker.tmp.last_update() <= self.timeout:
497+
if time.monotonic() - worker.tmp.last_update() <= self.timeout:
498498
continue
499499
except (OSError, ValueError):
500500
continue

gunicorn/workers/workertmp.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# See the NOTICE for more information.
55

66
import os
7+
import time
78
import platform
89
import tempfile
910

@@ -35,14 +36,12 @@ def __init__(self, cfg):
3536
os.close(fd)
3637
raise
3738

38-
self.spinner = 0
39-
4039
def notify(self):
41-
self.spinner = (self.spinner + 1) % 2
42-
os.fchmod(self._tmp.fileno(), self.spinner)
40+
new_time = time.monotonic()
41+
os.utime(self._tmp.name, (new_time, new_time))
4342

4443
def last_update(self):
45-
return os.fstat(self._tmp.fileno()).st_ctime
44+
return os.fstat(self._tmp.fileno()).st_mtime
4645

4746
def fileno(self):
4847
return self._tmp.fileno()

0 commit comments

Comments
 (0)