Repository navigation
gh-162217: Shield shared stdin close future to avoid InvalidStateError - #162284
mathisbusanabussei359-web wants to merge 2 commits into
Conversation
…reamProtocol Cancelling one waiter on stdin.wait_closed() must not cancel the shared future used by pipe_connection_lost()
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
There was a problem hiding this comment.
There is already a test class for subprocesses - SubprocessMixin
I think you should move the test there. After that android / ios CI should pass
| sys.executable, "-c", "import sys; sys.stdin.buffer.read()", | ||
| stdin=asyncio.subprocess.PIPE, | ||
| ) | ||
| stdin = proc.stdin |
There was a problem hiding this comment.
It's gonna be good to write test in the same order of operations as repro from issue do
After await asyncio.create_subprocess_exec(...), stdin.close() should be called before starting the wait_closed() tasks
|
You need to create a news entry. Can be added with |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Fixes #162217
Cancelling a task that is awaiting
proc.stdin.wait_closed()wascancelling the shared
_stdin_closedfuture. When the real closehappened later,
pipe_connection_losttried to set the result on analready-cancelled future → InvalidStateError.
Solution: return
tasks.shield(self._stdin_closed)so that cancellingone waiter does not affect the shared future.
Added a regression test that creates two waiters, cancels one, then
closes stdin and checks that the remaining waiter succeeds and no
exception handler is triggered.
stdin.wait_closed()cancels the shared close future, thenpipe_connection_lost()raisesInvalidStateError#162217