我试图等待stdout完成写入文件.有没有人对我如何做到这一点有任何想法?
下面这段代码:
代码:全选
session = open("c:\\sessionID.txt", "w")
#Execute previous exe and output session to text file from the current directory
cmd = os.path.realpath(os.getcwd()) +"\\Program.exe"
cmd = [os.getcwd() + '\\AOSLaunch.exe']
Execute the cmd which executes the program.exe and the output is saved to the sessionID.txt file
process = subprocess.Popen(cmd, stdout=session)
session.close()
Run Code Online (Sandbox Code Playgroud)
所以这里的问题是program.exe启动并将输出保存到stdout所花费的时间可能需要一些时间,有时sessionID.txt文件为空,因为它需要太长时间.在这里,我想确保stdout已写入sessionID.txt.
任何帮助是极大的赞赏.非常感谢TMARZI
| 归档时间: |
|
| 查看次数: |
1712 次 |
| 最近记录: |