Python使用subprocess.Popen导致子进程hang住
2013-02-05 19:05
567 查看
subprocess用于在python内部创建一个子进程,比如调用shell脚本等。
举例:
在python的官方文档中对这个进行了解释:http://docs.python.org/2/library/subprocess.html
原因是stdout产生的内容太多,超过了系统的buffer
解决方法是使用communicate()方法。
举例:
p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stdin = subprocess.PIPE, shell = True) p.wait() // hang here print "subprocess finished"
在python的官方文档中对这个进行了解释:http://docs.python.org/2/library/subprocess.html
原因是stdout产生的内容太多,超过了系统的buffer
解决方法是使用communicate()方法。
p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stdin = subprocess.PIPE, shell = True) stdout, stderr = p.communicate() p.wait() print "subprocess finished"
相关文章推荐
- Python模块之subprocess--使用Popen来调用系统命令
- python 使用 subprocess.Popen() 调用子进程
- 使用 subprocess.Popen 创建子进程
- Python subprocess.Popen communicate() 和wait()使用上的区别
- python subprocess Popen
- subprocess.popen.kill杀死所有子进程
- Python执行cmd的各种实现方法及优劣(subprocess.Popen, os.system和commands.getstatusoutput)
- Python执行shell脚本的几种方式(最好用subprocess.Popen来替代os.system)
- python执行系统命令的方法:os.system(), os.popen(), subprocess.Popen()
- python subprocess.Popen 非阻塞
- The easy way to execute sudo command in Python using subprocess.Popen
- Python_cmd的各种实现方法及优劣(subprocess.Popen, os.system和commands.getstatusoutput)
- subprocess.Popen指令包含中文导致乱码问题解决
- Python 脚本无法使用IDLE's subprocess didn't make connection
- 关于python subprocess的popen
- Python Subprocess Popen 管道阻塞问题分析解决
- windows下python subprocess.Popen执行adb 命令进程无法终止
- Python_cmd的各种实现方法及优劣(subprocess.Popen, os.system和commands.getstatusoutput)
- Python_cmd的各种实现方法及优劣(subprocess.Popen, os.system和commands.getstatusoutput)
- 解决大量调用Python subprocess.Popen产生的一些bug