def kill(pidfile, waittime=15):
"""
This method kills the process identified by pidfile.
:param pidfile: Name of the pidfile identifying the process to kill
:param waittime: Number of seconds to wait before killing the process
:type pidfile: str
:type waittime: int
"""
pid = read_pidfile(pidfile)
if psutil.pid_exists(pid):
p = psutil.Process(pid)
if p is not None:
p.terminate()
try:
p.wait(timeout=waittime)
except Exception as e:
pass
if p.is_running():
logger.warning("Killing process")
p.kill()
评论列表
文章目录