[python] wait process until all subprocess finish?

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

The answer is


subprocess.call

Automatically waits , you can also use:

p1.wait()

Examples related to python

programming a servo thru a barometer Is there a way to view two blocks of code from the same file simultaneously in Sublime Text? python variable NameError Why my regexp for hyphenated words doesn't work? Comparing a variable with a string python not working when redirecting from bash script is it possible to add colors to python output? Get Public URL for File - Google Cloud Storage - App Engine (Python) Real time face detection OpenCV, Python xlrd.biffh.XLRDError: Excel xlsx file; not supported Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

Examples related to subprocess

Subprocess check_output returned non-zero exit status 1 OSError: [Errno 8] Exec format error OSError: [WinError 193] %1 is not a valid Win32 application How to catch exception output from Python subprocess.check_output()? Subprocess changing directory OSError: [Errno 2] No such file or directory while using python subprocess in Django live output from subprocess command running multiple bash commands with subprocess Understanding Popen.communicate wait process until all subprocess finish?

Examples related to ipc

wait process until all subprocess finish? Example of Named Pipes Combining node.js and Python On localhost, how do I pick a free port number? IPC performance: Named Pipe vs Socket What is the simplest method of inter-process communication between 2 C# processes?