I have a main process which creates two or more sub processes, I want main process to wait until all sub processes finish their operations and exits?
# main_script.py
p1 = subprocess.Popen(['python script1.py'])
p2 = subprocess.Popen(['python script2.py'])
...
#wait main process until both p1, p2 finish
...
This question is related to
python
subprocess
ipc
subprocess.call
Automatically waits , you can also use:
p1.wait()
Source: Stackoverflow.com