This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients gregory.p.smith, l4mer, martin.panter, r.david.murray
Date 2017-10-07.00:41:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507336875.67.0.213398074469.issue31712@psf.upfronthosting.co.za>
In-reply-to
Content
Presumuing your file descriptor 3 is the read end of the pipe to the child’s output, then there is probably a process somewhere that could still write to the write end. Normally “check_output” waits until it has read all possible output from the pipe(s).

This is probably not a bug in Python. Maybe it is a bug with SSH or your “MUX” (you didn’t explain what that is) leaving a process running in the background that could output to stderr. Try to track down what processes have your pipe open. Find out the number that identifies the pipe. It is the node number in the “lsof” command, or in the symbolic link under /proc:

$ lsof -a -c python -d 3
COMMAND   PID    USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
python3 26025 vadmium    3r  FIFO    0,8      0t0 4913217 pipe
$ ls -l "/proc/$(pgrep python)/fd/3"
lr-x------ 1 vadmium vadmium 64 Oct  6 22:17 /proc/26025/fd/3 -> pipe:[4913217]

Then look through the other files to find if other process(es) have the write end of the pipe open; “cat” in my example:

$ lsof | grep 4913217
python3   26025       vadmium    3r     FIFO        0,8      0t0    4913217 pipe
cat       26026       vadmium    1w     FIFO        0,8      0t0    4913217 pipe
$ ls -l /proc/*/fd/* | grep 4913217
lr-x------ 1 vadmium vadmium 64 Oct  6 22:17 /proc/26025/fd/3 -> pipe:[4913217]
l-wx------ 1 vadmium vadmium 64 Oct  6 22:16 /proc/26026/fd/1 -> pipe:[4913217]

The general problem does seem to be a recurring thing with the subprocess module, so maybe more documentation or other enhancements could help. Similar reports:

* Issue 31447: communicate not respecting timeout due to grandchild process
* Issue 30154: subprocess.run with timeout and output pipe from grandchild
* Issue 26534: check_output with shell=True and timeout doesn’t kill shell’s child
* Issue 23213: communicate hang with stderr leaked in “systemd” daemon
* Issue 13422: communicate hangs as long as a daemon leaves pipes open
* Issue 4216: communicate hang after starting “cpboot” service
History
Date User Action Args
2017-10-07 00:41:15martin.pantersetrecipients: + martin.panter, gregory.p.smith, r.david.murray, l4mer
2017-10-07 00:41:15martin.pantersetmessageid: <1507336875.67.0.213398074469.issue31712@psf.upfronthosting.co.za>
2017-10-07 00:41:15martin.panterlinkissue31712 messages
2017-10-07 00:41:13martin.pantercreate