If you do
subprocess.run(["echo hi && sleep 60"], shell=True, capture_output=False, timeout=5)
you will see 'hi' printed to the terminal and then an exception will be thrown due to the timeout.
But if you do
ret = subprocess.run(["echo hi && sleep 6"], capture_output=True, timeout=2, shell=True)
You won't see any output, and the timeout exception will (as far as I can tell) prevent you from getting the output that was produced. (The shell=True is not important for this example, I just needed a convenient way to make it timeout.)
This is causing issues where I (a) need to get the output of the command but (b) sometimes am inadvertently running commands that hang waiting for user input. I'd really like to be able to capture any output produced despite a Timeout Exception being thrown or stream the output to stdout/stderr while also getting a copy of it.
sleepwas changed from 60 to 6 (3) thatcapture_outputchanged fromFalsetoTrue(4) thattimeoutwas changed from 5 to 2 (5) that the order of the arguments has been changed around? It would be nice to see two examples where only one thing changes.