def _shutdown(self): # Shut down the hook invoker threads; they will finish any current # work and then terminate. (The process will not exit until the invoker # threads stop; they are not daemon threads.) self._hooks.stop() monitor = ProcessMonitor.get_instance() monitor.observe("empty", self._subprocesses_all_exited) # Stop any recording tasks that are in progress. Shutdown will continue # when all recording subprocesses exit. for key, session in self._manager.get_all_sessions(): try: session.stop() except RuntimeError: pass
def _subprocesses_all_exited(self): ProcessMonitor.get_instance().halt() self.fire("shutdown")