daemon.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:smarthome 作者: smarthomeNG 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号