gh-145541: Fix InvalidStateError in BaseSubprocessTransport._call_connection_lost()#145554
gh-145541: Fix InvalidStateError in BaseSubprocessTransport._call_connection_lost()#145554kumaraditya303 merged 1 commit intopython:mainfrom
Conversation
|
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 |
|
Please set a more useful title than "wip" for your PR draft. |
|
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 |
|
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 |
|
Ping @kumaraditya303 |
…ll_connection_lost() Change `if not waiter.cancelled()` to `if not waiter.done()` in both _try_finish() and _call_connection_lost() so that waiters whose result was already set by _try_finish() are not set again by _call_connection_lost(), which would raise InvalidStateError. When _connect_pipes is cancelled (e.g. by SIGINT during subprocess creation), _pipes_connected stays False. If the process then exits, _try_finish() sets the result on exit waiters because _pipes_connected is False, and then schedules _call_connection_lost() because all pipes are disconnected. _call_connection_lost() must skip waiters that are already done.
|
Thanks @daandemeyer for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…_call_connection_lost()` (pythonGH-145554) (cherry picked from commit 1564e231aae7afad5b9b19a277d1efff2b840ad2) Co-authored-by: Daan De Meyer <daan.j.demeyer@gmail.com>
…_call_connection_lost()` (pythonGH-145554) (cherry picked from commit 1564e231aae7afad5b9b19a277d1efff2b840ad2) Co-authored-by: Daan De Meyer <daan.j.demeyer@gmail.com>
|
GH-145676 is a backport of this pull request to the 3.14 branch. |
|
GH-145677 is a backport of this pull request to the 3.13 branch. |
Change
if not waiter.cancelled()toif not waiter.done()in both_try_finish() and _call_connection_lost() so that waiters whose result
was already set by _try_finish() are not set again by
_call_connection_lost(), which would raise InvalidStateError.
When _connect_pipes is cancelled (e.g. by SIGINT during subprocess
creation), _pipes_connected stays False. If the process then exits,
_try_finish() sets the result on exit waiters because _pipes_connected
is False, and then schedules _call_connection_lost() because all pipes
are disconnected. _call_connection_lost() must skip waiters that are
already done.