python中subprocess.Popen.poll


import subprocess

proc = subprocess.Popen(['python', 'test.py'], stdout=subprocess.PIPE)

while 1:
    print proc.poll() 
#while 1:
#     print "hello"

print "hello"

测试代码如上,poll函数返回码:

0 正常结束

1 sleep

2 子进程不存在

-15 kill

None 在运行

 

poll的返回: A None value indicates that the process hasn’t terminated yet.A negative value -N indicates that the child was terminated by signal N (Unix only).  

ps:=====================================================================================================

self.proc.poll() == 0 判断子进程是否正常结束 正确
self.proc.poll() <= 0 会导致进程在一段时间内没有上报状态 具体原因??? 有问题

 

self.proc.poll() is not  None判断进行是否结束

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM