python subprocess.Popen hanging

Add close_fds=True to the call to subprocess.Popen() as mentioned here.


You're likely hitting the deadlock that's explained in the documentation:

Popen.wait():

Wait for child process to terminate. Set and return returncode attribute.

Warning: This will deadlock when using stdout=PIPE and/or stderr=PIPE and the child process generates enough output to a pipe such that it blocks waiting for the OS pipe buffer to accept more data. Use communicate() to avoid that.

The solution is to use Popen.communicate().