手机
当前位置:查字典教程网 >脚本专栏 >python >python定时检查某个进程是否已经关闭的方法
python定时检查某个进程是否已经关闭的方法
摘要:本文实例讲述了python定时检查某个进程是否已经关闭的方法。分享给大家供大家参考。具体如下:importthreadingimportti...

本文实例讲述了python定时检查某个进程是否已经关闭的方法。分享给大家供大家参考。具体如下:

import threading import time import os import subprocess def get_process_count(imagename): p = os.popen('tasklist /FI "IMAGENAME eq %s"' % imagename) return p.read().count(imagename) def timer_start(): t = threading.Timer(120,watch_func,("is running...")) t.start() def watch_func(msg): print "I'm watch_func,",msg if get_process_count('main.exe') == 0 : print subprocess.Popen([r'D:shuajibinmain.exe']) timer_start() if __name__ == "__main__": timer_start() while True: time.sleep(1)

希望本文所述对大家的Python程序设计有所帮助。

【python定时检查某个进程是否已经关闭的方法】相关文章:

python 不关闭控制台的实现方法

python实现网页链接提取的方法分享

python定时检查启动某个exe程序适合检测exe是否挂了

Python中使用中文的方法

python去掉字符串中重复字符的方法

python实现跨文件全局变量的方法

Python去掉字符串中空格的方法

wxpython中利用线程防止假死的实现方法

python爬取网站数据保存使用的方法

python操作日期和时间的方法

精品推荐
分类导航