def sigint_handler(sig, frame):
print("Killing sub-process...")
if process_handle is not None:
global kill_retry_count
while process_handle.returncode is None and kill_retry_count < kill_retry_max:
kill_retry_count += 1
print("Killing sub-process ({})...".format(kill_retry_count))
try:
os.killpg(os.getpgid(process_handle.pid), signal.SIGTERM)
os.waitpid(process_handle.pid, os.WNOHANG)
except ProcessLookupError:
break
try:
process_handle.wait(1)
except subprocess.TimeoutExpired:
pass
if working_dir is not None:
rmdir(working_dir)
sys.exit(0)
评论列表
文章目录