def _kill(self, process):
try:
process.terminate()
except ProcessLookupError:
# Python 3
return
except OSError as e:
if e.errno != errno.ESRCH:
raise
return
try:
self._wait(process)
except tenacity.RetryError:
LOG.warning("PID %d didn't terminate cleanly after 10 seconds, "
"sending SIGKILL to its process group", process.pid)
# Cleanup remaining processes
try:
pgrp = os.getpgid(process.pid)
except OSError as e:
# ESRCH is returned if process just died in the meantime
if e.errno != errno.ESRCH:
raise
else:
os.killpg(pgrp, signal.SIGKILL)
process.wait()
评论列表
文章目录