Here\'s the Python code to run an arbitrary command returning its stdout
data, or raise an exception on non-zero exit codes:
proc = subprocess.P
Unfortunately, I'm bound by very strict policies on the disclosure of source code by my employer, so I can't provide actual code. But for my taste the best solution is to create a subclass overriding Popen.wait()
to poll instead of wait indefinitely, and Popen.__init__
to accept a timeout parameter. Once you do that, all the other Popen
methods (which call wait
) will work as expected, including communicate
.