在我的python腳本中,我需要在for循環中調用一個可執行文件,然後等待該可執行文件將結果寫入「output.xml」。循環一個可執行文件以從Python腳本中獲取結果
我該如何設法使用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)