gh-145311: fix ensurepip and venv hang when stdin is a pipe#146010
Closed
lex00 wants to merge 2 commits intopython:mainfrom
Closed
gh-145311: fix ensurepip and venv hang when stdin is a pipe#146010lex00 wants to merge 2 commits intopython:mainfrom
lex00 wants to merge 2 commits intopython:mainfrom
Conversation
Pass `stdin=subprocess.DEVNULL` to the subprocess calls in `ensurepip._run_pip()` and `venv.EnvBuilder._call_new_python()` so they do not inherit an open pipe from the parent process and hang waiting for input that never arrives.
Member
|
There is no consensus on whether the issue is accepted. Please avoid opening PRs for issues that are not yet triaged. Thanks. |
This file contains hidden or 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
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.Suggestion cannot be applied right now. Please check back later.
When a process spawns Python with an open pipe on stdin and never writes to it,
ensurepip._run_pip()andvenv.EnvBuilder._call_new_python()can hang indefinitely because the subprocess inherits the pipe and blocks waiting for input.Fix: pass
stdin=subprocess.DEVNULLto both calls.Regression tests added for both code paths: a mock-based test that checks the kwarg is set, and an integration test that reproduces the hang condition with a real subprocess.
#145311