def force_kill_on_exit(proc): try: yield except: log.error('original error', exc_info=True) raise finally: if proc.is_alive(): proc.join(WAIT) if proc.is_alive(): # force kill os.kill(proc.pid, signal.SIGKILL) raise RuntimeError('Had to force kill broker process. ' 'Worker subprocesses may be orphaned.')
def verify(): return not proc.is_alive()