在我的python脚本中,我需要在for循环中调用一个可执行文件,并等待该可执行文件将结果写入“output.xml”。
我如何设法使用 wait() 以及我如何知道我的一个可执行文件何时完成生成结果以获得结果?如何关闭该进程并打开一个新进程以再次调用可执行文件并等待新结果?
import subprocess
args = ("bin/bar")
popen = subprocess.Popen(args)
我需要等待“bin/bar”的输出来生成“output.xml”,然后从那里读取它的内容。
for index, result in enumerate(results):
myModule.callSubProcess(index)
#this is where the problem is.
fileOutput = open("output.xml")
parseAndStoreInSQLiteFileOutput(index, file)