run subprocesses in parallel
Christian Heimes
lists at cheimes.de
Mon Aug 2 08:21:38 EDT 2010
> I want to run several subprocesses. Like so:
>
> p1 = Popen("mycmd1" + " myarg", shell=True)
> p2 = Popen("mycmd2" + " myarg", shell=True)
> ....
> pn = Popen("mycmdn" + " myarg", shell=True)
>
> What would be the most elegant and secure way to run all n
> subprocesses in parallel?
They already run in parallel. Depending on your command this may not be
secure due to race conditions. You might want to drop shell=True and use
a list as arguments instead. The shell=True argument is frowned upon and
should only be used if your really, really need a shell.
More information about the Python-list
mailing list