欢迎来到山村网

python定时检查某个进程是否已经关闭的方法

2019-03-02 12:57:22浏览:907 来源:山村网   
核心摘要:  本文实例讲述了python定时检查某个进程是否已经关闭的方法。分享给大家供大家参考。具体如下:  ? 1234567891011121314151

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

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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中用split()方法分割字符串的使用

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com