Skip to content

Commit

Permalink
Merge pull request #1967 from skytoup/master
Browse files Browse the repository at this point in the history
Fix #1965: About gunicorn [CRITICAL] Worker Timeout
  • Loading branch information
tilgovi committed Dec 28, 2023
2 parents bd734c5 + fd80918 commit b5d78e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gunicorn/arbiter.py
Expand Up @@ -495,7 +495,7 @@ def murder_workers(self):
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
Expand Down
6 changes: 4 additions & 2 deletions gunicorn/workers/workertmp.py
Expand Up @@ -4,6 +4,7 @@
# See the NOTICE for more information.

import os
import time
import platform
import tempfile

Expand Down Expand Up @@ -40,10 +41,11 @@ def __init__(self, cfg):
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()
Expand Down

0 comments on commit b5d78e8

Please sign in to comment.