python中subprocess.Popen.poll
2016-04-10 20:05
387 查看
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判断进行是否结束
相关文章推荐
- 【python】matplotlib生成散点矩阵图
- python的逻辑语句
- python+caffe做图片处理可能会用到的方法
- 2016.4.10Python列表生成式及生成器generator
- python全局变量的使用错误
- Sublime Text 3 python 配置
- 华为OJ平台练习题
- python之sys
- Python collections OrderedDict
- python的Image和skimage处理图片
- think python chapter2
- Python os模块
- think python chapter3
- ubuntu中用python把文件的编码改成utf8
- [python]使用txt保存和读取列表变量
- python中的错误处理
- python 装饰器和 functools 模块
- python对robotframework测试概要信息报告发送邮件的方法
- Python学习笔记第一天
- (python解析js)scrapy结合ghost抓取js生成的页面,以及js变量的解析