手机
当前位置:查字典教程网 >脚本专栏 >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获取当前时间的方法

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

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

Python转码问题的解决方法

python list 合并连接字符串的方法

Python编写检测数据库SA用户的方法

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

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

精品推荐
分类导航