I'm currently running some subprocesses in parallel(multiple subprocesses), {p1, p2, p3, p4}.
I'd like to wait() until any of them finishes.
I'm currently polling in a while loop which is probably very inefficient
proc = [p1, p2, p3, p4]
while True:
for p in proc:
if p.poll() != None:
#Do whatever
I was wondering, is there a way to wait for the fastest finishing subprocess instead of busy waiting polling through all the subprocesses?