Run some subrocesses at a time - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Run some subrocesses at a time (/thread-30908.html) |
Run some subrocesses at a time - OmegaDoom - Nov-12-2020 Hello. Lets say we need to run 100-1000 subprocesses to do some work. Each subprocess is some kind of app, for example zip. it is not good to spawn all process at a time. We need to limit them. But the question is how can we monitor that a subpocess has finished and it is time to start a new one? procs_list = [Popen(arg) for arg in args] for proc in procs_list: proc.wait()This doesn't work because it waits all processes to finish but we need to spawn a new one as soon as any subprocess has finished. I think it comes down to a question if it possible to determine if any process from a list has finished. |