Skip to content

Commit

Permalink
Assume safe iteration of workers in the arbiter
Browse files Browse the repository at this point in the history
With reaping handled in the main execution context and kill_worker
delegating responsibility for cleanup to the reaping loop, iterate over
the workers dictionary everywhere else without concern for concurrent
modification.
  • Loading branch information
tilgovi committed Apr 20, 2020
1 parent 6980b40 commit 0b5d41b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions gunicorn/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ def murder_workers(self):
"""
if not self.timeout:
return
workers = list(self.WORKERS.items())
for (pid, worker) in workers:
for (pid, worker) in self.WORKERS.items():
try:
if time.time() - worker.tmp.last_update() <= self.timeout:
continue
Expand Down Expand Up @@ -621,8 +620,7 @@ def kill_workers(self, sig):
Kill all workers with the signal `sig`
:attr sig: `signal.SIG*` value
"""
worker_pids = list(self.WORKERS.keys())
for pid in worker_pids:
for pid in self.WORKERS:
self.kill_worker(pid, sig)

def kill_worker(self, pid, sig):
Expand Down

0 comments on commit 0b5d41b

Please sign in to comment.