码迷,mamicode.com
首页 > 编程语言 > 详细

python 子进程超时退出

时间:2014-09-05 09:55:51      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   div   sp   log   on   c   

一:循环 忙等 子进程结束

import subprocess  
import os  
import time  
tt = 555  
cmd = "python /home/100003/python/mypython/sub2.py "+" 333"+" 444 "+tt  
print time.time()  
sub2 = subprocess.Popen(cmd, shell=True)  
while 1:  
    ret1 = subprocess.Popen.poll(sub2)  
    if ret1 == 0:  
        print sub2.pid,end  
        break  
    elif ret1 is None:  
        print  running  
        time.sleep(1)  
    else:  
        print sub2.pid,term  
        break  
print time.time()  

 

python 子进程超时退出

标签:style   blog   color   os   div   sp   log   on   c   

原文地址:http://www.cnblogs.com/taotaowill/p/3957255.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!