我尝试为这个python 错误调用想出一个解决方法subprocess。我认为要走的路是os.system结合使用os.waitpid. 为了测试这一点,我编写了下面的代码。system_call_test.py将pid大量文本写入文件f。但是打电话os.waitpid()总是给我这个错误:OSError: [Errno 10] No child processes。所以我很难检查这个构造是否正常工作。如何确保脚本等待另一个终止。我在 Windows XP/python 2.7 上。
import os
f = r'D:\temp\called.txt'
s = os.system('C:\Python27\python.exe D:\python_spullen\system_call_test.py')
with open(f, 'r') as f_in:
i = f_in.readline()[-4:]
print i
rr = os.waitpid(int(i),0)
print rr