简体   繁体   中英

wait a process to finish in Python script

I'm writing a Python script to run several executables one by one on Windows. I need to wait a program to finish before starting the next.

So the script will be like this.

1: launch a.exe
2: wait till a.exe finishes running
3: launch b.exe
4: wait till b.exe finishes 

Anyone have an idea how to make the script waiting for a process to finish in Python?

Thanks

If you wish to wait for your launched process, you can simply use subprocess.call() . This method executes the command in args and waits for it to complete. For reference, see this

import subprocess
subprocess.call(('someprog.exe', str(i)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM