How to wait for multiple child processes in Python on Windows, without active wait (polling)? Something like this almost works for me:
proc1 = subprocess.Popen(['python','mytest.py'])
proc2 = subprocess.Popen(['python','mytest.py'])
proc1.wait()
print "1 finished"
proc2.wait()
print "2 finished"
The problem is that when proc2
finishes before proc1
, the parent process will still wait for proc1
. On Unix one would use waitpid(0)
in a loop to get the child processes' return codes as they finish - how to achieve something like this in Python on Windows?