Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
gvanrossum merged 6 commits intopython:mainfromdpr-0:closed-loop-runtime-error
Nov 15, 2023

Conversation

dpr-0
Copy link
Contributor

@dpr-0dpr-0 commentedNov 11, 2023
edited
Loading

Catch RuntimeError("Event loop is closed") from base_events.py line 514 then issue a warning to user

edgarrmondragon reacted with thumbs up emoji
@ghost
Copy link

ghost commentedNov 11, 2023
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

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 theskip news label instead.

@bedevere-app
Copy link

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 theskip news label instead.

@AlexWaygoodAlexWaygood added type-bugAn unexpected behavior, bug, or error topic-asyncio labelsNov 11, 2023
@dpr-0dpr-0force-pushed theclosed-loop-runtime-error branch 2 times, most recently from5dd6f38 toa0dbe8bCompareNovember 11, 2023 17:08
@dpr-0dpr-0force-pushed theclosed-loop-runtime-error branch from2f72974 to075a7fdCompareNovember 12, 2023 01:59
@dpr-0dpr-0force-pushed theclosed-loop-runtime-error branch from075a7fd to7461e4eCompareNovember 12, 2023 02:02
@hugovk
Copy link
Member

Tip:

In order to keep the commit history intact, please avoid squashing or amending history and then force-pushing to the PR. Reviewers often want to look at individual commits.

https://devguide.python.org/getting-started/pull-request-lifecycle/#quick-guide

dpr-0 reacted with heart emoji

@dpr-0
Copy link
ContributorAuthor

Tip:

In order to keep the commit history intact, please avoid squashing or amending history and then force-pushing to the PR. Reviewers often want to look at individual commits.

https://devguide.python.org/getting-started/pull-request-lifecycle/#quick-guide

I see, thanks for letting me know.

hugovk reacted with thumbs up emoji

Copy link
Member

@gvanrossumgvanrossum left a 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.


try:
self.close()
except RuntimeError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Catching allRuntimeErrors always feels scary -- it could mark other, more serious bugs. How about only issuing the new warning ifself._loop.is_closed()?

dpr-0 and willingc reacted with thumbs up emoji
Copy link
Member

@gvanrossumgvanrossum left a 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?

Copy link
Contributor

@willingcwillingc left a 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

dpr-0 reacted with thumbs up emoji
@miss-islington-app
Copy link

Thanks@dpr-0 for the PR, and@gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry,@dpr-0 and@gvanrossum, I could not cleanly backport this to3.12 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker e0f512797596282bff63260f8102592aad37cdf1 3.12

@miss-islington-app
Copy link

Sorry,@dpr-0 and@gvanrossum, I could not cleanly backport this to3.11 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker e0f512797596282bff63260f8102592aad37cdf1 3.11

@dpr-0dpr-0 deleted the closed-loop-runtime-error branchNovember 15, 2023 01:28
@gvanrossum
Copy link
Member

@dpr-0 Are you interested in attempting the backports?

@dpr-0
Copy link
ContributorAuthor

@dpr-0 Are you interested in attempting the backports?

Yes, any brief backport steps or I just cherry-pick and create two PRs?

@gvanrossum
Copy link
Member

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.

dpr-0 and willingc reacted with thumbs up emoji

try:
self.loop.run_until_complete(inner(httpd))
# This exception is caused by `self.loop.stop()` as expected.
except RuntimeError:
Copy link
Contributor

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?

Copy link
Member

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
Copy link
ContributorAuthor

dpr-0 commentedNov 16, 2023
edited
Loading

@kumaraditya303@gvanrossum I am planning to backport this PR and issue a new PR to improve test case.

dpr-0 added a commit to dpr-0/cpython that referenced this pull requestNov 16, 2023
… closed loop (python#111983)Issue a ResourceWarning instead.Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>(cherry picked from commite0f5127)
@bedevere-app
Copy link

GH-112141 is a backport of this pull request to the3.11 branch.

@bedevere-app
Copy link

GH-112142 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelNov 16, 2023
dpr-0 added a commit to dpr-0/cpython that referenced this pull requestNov 16, 2023
…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)
@bedevere-app
Copy link

GH-112141 is a backport of this pull request to the3.12 branch.

@bedevere-app
Copy link

GH-112141 is a backport of this pull request to the3.11 branch.

@bedevere-app
Copy link

GH-112142 is a backport of this pull request to the3.12 branch.

gvanrossum pushed a commit that referenced this pull requestNov 16, 2023
…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
gvanrossum pushed a commit that referenced this pull requestNov 20, 2023
…H-111983) (#112141)Issue a ResourceWarning instead.Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>(cherry picked from commite0f5127)
aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
… closed loop (python#111983)Issue a ResourceWarning instead.Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
… closed loop (python#111983)Issue a ResourceWarning instead.Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@hugovkhugovkhugovk left review comments

@willingcwillingcwillingc left review comments

@terryjreedyterryjreedyterryjreedy left review comments

@kumaraditya303kumaraditya303kumaraditya303 left review comments

@gvanrossumgvanrossumgvanrossum approved these changes

@1st11st1Awaiting requested review from 1st11st1 is a code owner

@asvetlovasvetlovAwaiting requested review from asvetlovasvetlov is a code owner

Assignees

@gvanrossumgvanrossum

Labels
topic-asynciotype-bugAn unexpected behavior, bug, or error
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

8 participants
@dpr-0@hugovk@gvanrossum@willingc@terryjreedy@kumaraditya303@AlexWaygood@Eclips4

[8]ページ先頭

©2009-2025 Movatter.jp