Skip to content

Commit

Permalink
Merge pull request #106 from geoffl/bz18517
Browse files Browse the repository at this point in the history
bz18517: Don't failed_soft() if we notice the thread was already gone.
  • Loading branch information
paulswartz committed Dec 2, 2011
2 parents 6ec57e8 + 4164e71 commit 555258b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tv/lib/subprocessmanager.py
Expand Up @@ -393,14 +393,29 @@ def shutdown(self, timeout=1.0):
def _on_thread_quit(self, thread):
"""Handle our thread exiting."""

# Igoner this call if it was queued from while we were in the middle
# Ignore this call if it was queued from while we were in the middle
# of shutdown().
if not self.is_running:
return

if thread is not self.thread:
app.controller.failed_soft('handling subprocess',
'_on_thread_quit called by an old thread')
# If we have lost the race between the cleanup on shutdown
# it should be safe to ignore.
#
# This can happen when the process does not immediately shut down
# because the worker process is still processing pending jobs
# and the quit message was not processed in time and so the
# subprocess was forcibly terminated. When that happens
# _cleanup_process() is called which resets the thread attribute
# to None immediately, but _on_thread_quit() is only run some
# time after that (when we notice the pipe to the subprocess's
# close we add _on_thread_quit() to the idle loop).
#
# So if the self.thread attribute is None then it means we are done
# and so things are all good.
if self.thread is not None:
app.controller.failed_soft('handling subprocess',
'_on_thread_quit called by an old thread')
return

if self.thread.quit_type == self.thread.QUIT_NORMAL:
Expand Down

0 comments on commit 555258b

Please sign in to comment.