Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better cleanup of dead processes. #1834

Merged
merged 6 commits into from
Jan 31, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions celery/concurrency/asynpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def verify_process_alive(proc):
if proc._is_alive() and proc in waiting_to_start:
assert proc.outqR_fd in fileno_to_outq
assert fileno_to_outq[proc.outqR_fd] is proc
assert proc.outqR_fd in hub.readers
assert proc.outqR_fd in hub.readers, "%s.outqR_fd=%s not in hub.readers !" % (proc, proc.outqR_fd)
error('Timed out waiting for UP message from %r', proc)
os.kill(proc.pid, 9)

Expand Down Expand Up @@ -570,6 +570,15 @@ def on_process_down(proc):
if inq:
busy_workers.discard(inq)
hub_remove(proc.sentinel)
waiting_to_start.discard(proc)
self._active_writes.discard(proc.inqW_fd)
hub_remove(proc.inqW_fd)
hub_remove(proc.outqR_fd)
if proc.synqR_fd:
hub_remove(proc.synqR_fd)
if proc.synqW_fd:
self._active_writes.discard(proc.synqW_fd)
hub_remove(proc.synqW_fd)
self.on_process_down = on_process_down

def _create_write_handlers(self, hub,
Expand Down Expand Up @@ -966,7 +975,7 @@ def on_process_alive(self, pid):
try:
proc = next(w for w in self._pool if w.pid == pid)
except StopIteration:
# process already exited :( this will be handled elsewhere.
logger.warning("process with pid=%s already exited :( - handling this elsewhere ...", pid)
return
assert proc.inqW_fd not in self._fileno_to_inq
assert proc.inqW_fd not in self._all_inqueues
Expand Down