Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-98703: Fix asyncio proactor_events calling _call_connection_lost multiple times#98704
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
gh-98703: Fix asyncio proactor_events calling _call_connection_lost multiple times #98704
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Fidget-Spinner commented Oct 26, 2022
@kumaraditya303 I don't know why but this started showing on our tests after #98572. I can't tell if that PR introduced a bug or it just exposed something wrong with our implementation. IMO, it seems it's something wrong with our implementation. |
kumaraditya303 commented Oct 26, 2022
Seriously though this has uncovered another race in our implementation. The code does not guard against concurrent closing of the stream which leads to this failure. The Here's a better fix: diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index 2685a3376c..c6aab408fc 100644 --- a/Lib/asyncio/proactor_events.py+++ b/Lib/asyncio/proactor_events.py@@ -152,6 +152,8 @@ def _force_close(self, exc): self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): + if self._called_connection_lost:+ return try: self._protocol.connection_lost(exc) finally: Feel free to update this PR with the patch above, I have verified this. |
Misc/NEWS.d/next/Library/2022-10-26-07-51-55.gh-issue-98703.0hW773.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
Co-Authored-By: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Fidget-Spinner commented Oct 26, 2022
Awesome! Thank you for the fix. I was trying to find something more elegant but I'm a noob at asyncio internals :). Your fix is way nicer. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-Authored-By: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
kumaraditya303 left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for the PR!
kumaraditya303 commented Oct 26, 2022
I created #98730 to add tests for this. |
gvanrossum left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ironic.
miss-islington commented Oct 27, 2022
Thanks @Fidget-Spinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
miss-islington commented Oct 27, 2022
Sorry @Fidget-Spinner, I had trouble checking out the |
bedevere-bot commented Oct 27, 2022
GH-98753 is a backport of this pull request to the 3.10 branch. |
…lost multiple times (pythonGH-98704) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> (cherry picked from commit 8a75542) Co-authored-by: Ken Jin <kenjin@python.org>
miss-islington commented Oct 27, 2022
Thanks @Fidget-Spinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
bedevere-bot commented Oct 27, 2022
GH-98754 is a backport of this pull request to the 3.11 branch. |
…lost multiple times (pythonGH-98704) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> (cherry picked from commit 8a75542) Co-authored-by: Ken Jin <kenjin@python.org>
…lost multiple times (pythonGH-98704) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.