Subprocess calls, are they executed in parallel?

I googled the answer to this question, but nowhere seems to be there. Can someone tell me if the subprocess module makes its calls in parallel? Python docs suggest that it can be used to spawn new processes, but it does not mention whether they are parallel or not. If they can be done in parallel, could you show me an example or connect me with one?

+9
source share
1 answer

It depends on how you use subprocess :

 subprocess.call("some-program") 

will be blocked until some-program .

 p = subprocess.Popen("some-program") 

will run some-program in a separate process in parallel with the rest of your script.

Please note: the first is just a convenient shell equivalent to

 subprocess.Popen("some-program").wait() 

output = subprocess.check_output("some-program") basically matches

 output, stderr = subprocess.Popen("some-program").communicate() 
+15
source

All Articles