The code in subprocess is actually quite simple and readable. Just review the 3.3 or 2.7 version (as needed) and you can tell what it does.
For example, call looks like this:
def call(*popenargs, timeout=None, **kwargs): """Run command with arguments. Wait for command to complete or timeout, then return the returncode attribute. The arguments are the same as for the Popen constructor. Example: retcode = call(["ls", "-l"]) """ with Popen(*popenargs, **kwargs) as p: try: return p.wait(timeout=timeout) except: p.kill() p.wait() raise
You can do the same without calling wait . Create a Popen , don't call wait on it, and that is exactly what you want.
abarnert
source share