watcher.py 文件源码

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

项目:taskSubmitter 作者: 1a1a11a 项目源码 文件源码
def watch(pid, name="no name", check_interval=1): 
    """ check the given process has finished or not 
        if it finishes, then send out email notification 
    :param pid: the pid of monitoring process 
    :param name: the name of process, this is optional, only used for notification 
    :param check_interval: how long the monitoring process should wait before next check 
    :return: None 

    """
    msg = 'task  “ {} ({}) ” on _{}_ just began executing! ✌'.format(name, pid, socket.gethostname())
    configEmailClient().send_email(message=msg, topic="Task Submitted") 

    while psutil.pid_exists(pid):
        time.sleep(check_interval)

    msg = 'task “ {} ({}) ” on _{}_ finished executing ✋'.format(name, pid, socket.gethostname())
    configEmailClient().send_email(message=msg, topic="Task Finished")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号