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 loop 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 Sep 13, 2020
1 parent 207f51c commit 8ef2e40
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 @@ -512,8 +512,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 @@ -644,8 +643,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 8ef2e40

Please sign in to comment.