def clean_proc(proc, wait_for_kill=10):
 if (not proc):
  return
 try:
  waited = 0
  while proc.is_alive():
   proc.terminate()
   waited += 1
   time.sleep(0.1)
   if (proc.is_alive() and (waited >= wait_for_kill)):
    log.error('Process did not die with terminate(): {0}'.format(proc.pid))
    os.kill(proc.pid, signal.SIGKILL)
 except (AssertionError, AttributeError):
  pass

def clean_proc ( proc , wait_for_kill = 10 ) : if ( not proc ) : return try : waited = 0 while proc . is_alive ( ) : proc . terminate ( ) waited += 1 time . sleep ( 0.1 ) if ( proc . is_alive ( ) and ( waited >= wait_for_kill ) ) : log . error ( 'Process did not die with terminate(): {0}' . format ( proc . pid ) ) os . kill ( proc . pid , signal . SIGKILL ) except ( AssertionError , AttributeError ) : pass
generic method for cleaning up multiprocessing procs .