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