From 4fe426cd669653ff8087c16718a29b21df3d1261 Mon Sep 17 00:00:00 2001 From: benoitc Date: Sat, 30 Aug 2014 09:26:54 +0200 Subject: [PATCH] fix race condition error When the worker exited the tempfile is not available anymore so we can't get the last update and calculate the dynamic timeout introduced in d76bab4d716fed3f965fbde4ba1a1bba975f03d1 . This changes fix it by catching the IO error. fix #863 --- gunicorn/arbiter.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index df2616f3..c34fff45 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -305,7 +305,15 @@ class Arbiter(object): """ if self.WORKERS: worker_values = list(self.WORKERS.values()) - oldest = min(w.tmp.last_update() for w in worker_values) + + oldest = time.time() + for w in worker_values: + try: + if w.tmp.last_update() < oldest: + oldest = w.tmp.last_update() + except ValueError: + pass + timeout = self.timeout - (time.time() - oldest) # The timeout can be reached, so don't wait for a negative value timeout = max(timeout, 1.0)