On some machine, for the following piece of code
p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT);
out, err = p.communicate()
This script would just hang at p.communicate() and does not return.
After I manually run the command, I finally see the error messages.
Why is this, and how should I solve it?
Thanks.
I guess your program never ends?
when you call communicate() it does different things under different os. But it always waits for the launched process to exit on its own eg. calls p.wait().
p.wait() terminates only if the rocess terminates.
Solutions:
way
If you want to look at the source of subprocess you can find it at
subprocess.__file__.