Skip to content

Commit

Permalink
fix race condition error
Browse files Browse the repository at this point in the history
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
d76bab4 .

This changes fix it by catching the IO error.

fix benoitc#863
  • Loading branch information
benoitc authored and paulnivin committed Dec 16, 2015
1 parent 8f1a497 commit edbf1ce
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gunicorn/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,15 @@ def sleep(self):
"""
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)
Expand Down

0 comments on commit edbf1ce

Please sign in to comment.