Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-109538: Catch closed loop runtime error and issue warning#111983
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedNov 11, 2023 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
5dd6f38
toa0dbe8b
CompareMisc/NEWS.d/next/Library/2023-11-11-16-42-48.gh-issue-109538.cMG5ux.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
2f72974
to075a7fd
Compare…MG5ux.rstCo-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
075a7fd
to7461e4e
CompareTip:
https://devguide.python.org/getting-started/pull-request-lifecycle/#quick-guide |
I see, thanks for letting me know. |
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.
Sorry to be arguing.
Lib/asyncio/streams.py Outdated
try: | ||
self.close() | ||
except RuntimeError: |
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.
Catching allRuntimeError
s always feels scary -- it could mark other, more serious bugs. How about only issuing the new warning ifself._loop.is_closed()
?
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.
Have you confirmed that this version solves the problem in your code? How hard would it be to write a unit test to confirm that this warning is reported?
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.
Change looks good. Thanks. Happy to merge after we have a test. This would be the file to add the test:https://github.com/python/cpython/blob/main/Lib/test/test_asyncio/test_streams.py
Thanks@dpr-0 for the PR, and@gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
Sorry,@dpr-0 and@gvanrossum, I could not cleanly backport this to
|
Sorry,@dpr-0 and@gvanrossum, I could not cleanly backport this to
|
@dpr-0 Are you interested in attempting the backports? |
Yes, any brief backport steps or I just cherry-pick and create two PRs? |
I think it's just a matter of checking out the right branch (3.11 or 3.12), cherry-picking the commit from main, resolving conflicts, and submitting a PR. Repeat for the other branch. The PR title should follow certain conventions (see either the devguide or just wait for the test to fail -- I always forget what it is and I use the latter). I don't know what caused the conflict -- if it's complicated just ping this thread with the conflict info. |
try: | ||
self.loop.run_until_complete(inner(httpd)) | ||
# This exception is caused by `self.loop.stop()` as expected. | ||
except RuntimeError: |
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.
If this exception is expected then why not useself.assertRaises
etc?
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.
except
allows/tolerates an exception,assert
requires one and will fail if it does not happen because of other improvements.
dpr-0 commentedNov 16, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@kumaraditya303@gvanrossum I am planning to backport this PR and issue a new PR to improve test case. |
… closed loop (python#111983)Issue a ResourceWarning instead.Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>(cherry picked from commite0f5127)
GH-112141 is a backport of this pull request to the3.11 branch. |
GH-112142 is a backport of this pull request to the3.12 branch. |
…ed with closed loop (pythonGH-111983)Issue a ResourceWarning instead.(cherry picked from commite0f5127)pythongh-109538: Avoid RuntimeError when StreamWriter is deleted with closed loop (python#111983)Issue a ResourceWarning instead.Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>(cherry picked from commite0f5127)
GH-112141 is a backport of this pull request to the3.12 branch. |
GH-112141 is a backport of this pull request to the3.11 branch. |
GH-112142 is a backport of this pull request to the3.12 branch. |
…H-111983) (#112142)* [3.12]gh-109538: Avoid RuntimeError when StreamWriter is deleted with closed loop (GH-111983)Issue a ResourceWarning instead.(cherry picked from commite0f5127)gh-109538: Avoid RuntimeError when StreamWriter is deleted with closed loop (#111983)Issue a ResourceWarning instead.Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>(cherry picked from commite0f5127)* Fix missing warnings import
… closed loop (python#111983)Issue a ResourceWarning instead.Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
… closed loop (python#111983)Issue a ResourceWarning instead.Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
Catch RuntimeError("Event loop is closed") from base_events.py line 514 then issue a warning to user