def kill(pid, sleep_time=1):
"""Kill ``pid`` with various signals.
Args:
pid (int): the process id to kill.
sleep_time (int, optional): how long to sleep between killing the pid
and checking if the pid is still running.
"""
siglist = [signal.SIGINT, signal.SIGTERM]
while True:
sig = signal.SIGKILL
if siglist: # pragma: no branch
sig = siglist.pop(0)
try:
os.kill(pid, sig)
await asyncio.sleep(sleep_time)
os.kill(pid, 0)
except (OSError, ProcessLookupError):
return
# max_timeout {{{1
评论列表
文章目录