New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-37424: Avoid a hang in subprocess.run timeout output capture #14490
Merged
Yhg1s
merged 7 commits into
python:master
from
gpshead:subprocess_timeout_shell_issue37424
Sep 11, 2019
Merged
bpo-37424: Avoid a hang in subprocess.run timeout output capture #14490
Yhg1s
merged 7 commits into
python:master
from
gpshead:subprocess_timeout_shell_issue37424
Sep 11, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When shell=True the user is often launching a process tree, if we kill only the shell and it hasn't set itself up as a pgrp leader, the grandchild processes still run and may have our output handles open. Leading us to wait forever when we should be timing out. This Adds a fractional timeout on the cleanup communicate phase _and_ will use killpg on the child process group _if_ it is different from our own as it should be when start_new_session=True was used.
If an API change is made to make the default behavior easier for people in the future, that part won't get backported to 3.7. 3.8 only. |
giampaolo
reviewed
Jul 1, 2019
vstinner
reviewed
Jul 1, 2019
Do not have a post-timeout sub-timeout for output collection, we've already got all of that output within POSIX's _communicate() method as it is.
gpshead
commented
Jul 4, 2019
that belongs in its own PR if at all.
it wasn't actually testing what it described as it never checked the grandchild process explicitly. redo this better in a later PR.
Yhg1s
reviewed
Sep 10, 2019
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Sep 11, 2019
…honGH-14490) Fixes a possible hang when using a timeout on subprocess.run() while capturing output. If the child process spawned its own children or otherwise connected its stdout or stderr handles with another process, we could hang after the timeout was reached and our child was killed when attempting to read final output from the pipes. (cherry picked from commit 580d278) Co-authored-by: Gregory P. Smith <greg@krypto.org>
GH-15897 is a backport of this pull request to the 3.8 branch. |
GH-15898 is a backport of this pull request to the 3.7 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Sep 11, 2019
…honGH-14490) Fixes a possible hang when using a timeout on subprocess.run() while capturing output. If the child process spawned its own children or otherwise connected its stdout or stderr handles with another process, we could hang after the timeout was reached and our child was killed when attempting to read final output from the pipes. (cherry picked from commit 580d278) Co-authored-by: Gregory P. Smith <greg@krypto.org>
miss-islington
added a commit
that referenced
this pull request
Sep 11, 2019
…14490) Fixes a possible hang when using a timeout on subprocess.run() while capturing output. If the child process spawned its own children or otherwise connected its stdout or stderr handles with another process, we could hang after the timeout was reached and our child was killed when attempting to read final output from the pipes. (cherry picked from commit 580d278) Co-authored-by: Gregory P. Smith <greg@krypto.org>
miss-islington
added a commit
that referenced
this pull request
Sep 11, 2019
…14490) Fixes a possible hang when using a timeout on subprocess.run() while capturing output. If the child process spawned its own children or otherwise connected its stdout or stderr handles with another process, we could hang after the timeout was reached and our child was killed when attempting to read final output from the pipes. (cherry picked from commit 580d278) Co-authored-by: Gregory P. Smith <greg@krypto.org>
websurfer5
pushed a commit
to websurfer5/cpython
that referenced
this pull request
Jul 20, 2020
…honGH-14490) Fixes a possible hang when using a timeout on subprocess.run() while capturing output. If the child process spawned its own children or otherwise connected its stdout or stderr handles with another process, we could hang after the timeout was reached and our child was killed when attempting to read final output from the pipes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Fixes a possible hang when using a timeout on
subprocess.run()
whilecapturing output. If the child process spawned its own children or otherwise
connected its stdout or stderr handles with another process, we could hang
after the timeout was reached and our child was killed when attempting to read
final output from the pipes.
https://bugs.python.org/issue37424