我使用subprocess.Popen()
启动子流程并使用communicate()
方法获取输出。我试图实现超时约。如下(我目前没有实际的副本):
while p.poll() != 0 and theres_still_time():
sleep(1)
p.kill()
out,err=p.communicate()
在p.communicate()
之后拨打p.kill()
看起来很奇怪。虽然它不会引发错误,但它似乎并没有按时实际关闭该过程。
有办法:
所有在Windows 8.1的python 2.7中的相同进程?
如果解决方案可以使用环境变量(特别是路径变量),那么从shell执行是不必要的。