From bcdbc09f8f65cc34a0a0cc5d60e76d95d0cccd8e Mon Sep 17 00:00:00 2001 From: Michal Daniliszyn 1 Date: Fri, 12 Jul 2024 13:58:10 +0200 Subject: [PATCH] #3227: Use a monotonic clock to measure elapsed time. --- gunicorn/workers/ggevent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gunicorn/workers/ggevent.py b/gunicorn/workers/ggevent.py index 740bc8d11..960e50ec4 100644 --- a/gunicorn/workers/ggevent.py +++ b/gunicorn/workers/ggevent.py @@ -126,9 +126,9 @@ def _wait_for_keepalive(self, servers): # if any of those greenlets are still active. If none are active, exit the loop. greenlets = {id(greenlet) for server in servers for greenlet in server.pool.greenlets} - ts = time.time() + ts = time.monotonic() - while time.time() - ts <= self.cfg.keepalive: + while time.monotonic() - ts <= self.cfg.keepalive: if not greenlets.intersection({id(greenlet) for server in servers for greenlet in server.pool.greenlets}): break self.notify()