Author Martin Ritter
Recipients Martin Ritter
Date 2017-11-03.15:01:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1509721292.04.0.213398074469.issue31935@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

I tried to use 

    subprocess.run(..., stdout=subprocess.PIPE, timeout=N)

to run some test scripts with a given timeout. 

This works as expected with simple scripts. However if the script itself creates other children which write to stdout then `subprocess.run()` seems to wait for all of the children to finish. I've attached a minimal example.

I looked into subprocess.py and `subprocess.run()` calls `process.communicate()` again without timeout when handling the TimeoutExpired exception which then in turn waits for the pipes to be closed by all children.

If communicate() would check if the process is still alive while waiting for output and close the pipes once the process has finished the timeout feature should work as expected and descendants would get a SIGPIPE when writing to stdout/stderr.
History
Date User Action Args
2017-11-03 15:01:32Martin Rittersetrecipients: + Martin Ritter
2017-11-03 15:01:32Martin Rittersetmessageid: <1509721292.04.0.213398074469.issue31935@psf.upfronthosting.co.za>
2017-11-03 15:01:31Martin Ritterlinkissue31935 messages
2017-11-03 15:01:31Martin Rittercreate