-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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-126353: remove implicit creation of loop from get_event_loop
#126354
Conversation
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.
Please add also versionchanged
directives in the documentation and the What's New entry.
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.
Update also Doc/library/asyncio-policy.rst
. Look if there are other mentions of get_event_loop()
that needs to be updated.
Misc/NEWS.d/next/Library/2024-11-03-10-48-07.gh-issue-126353.ChDzot.rst
Outdated
Show resolved
Hide resolved
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.
I was waiting for this date for many years :)
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. 👍
@@ -924,7 +924,7 @@ def test_python_gil(self): | |||
self.assertEqual(proc.stderr, '') | |||
|
|||
def test_python_asyncio_debug(self): | |||
code = "import asyncio; print(asyncio.get_event_loop().get_debug())" | |||
code = "import asyncio; print(asyncio.new_event_loop().get_debug())" |
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.
I think this needs a with contextlib.closing(...
to prevent the test suite printing a ResourceWarning
@@ -576,6 +576,11 @@ asyncio | |||
|
|||
(Contributed by Kumar Aditya in :gh:`120804`.) | |||
|
|||
* Removed implicit creation of event loop by :func:`asyncio.get_event_loop`. | |||
It now raises a :exc:`RuntimeError` if there is no current event loop. | |||
(Contributed by Kumar Aditya in :gh:`126353`.) |
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.
Could you please mention what should be used instead?
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.
new_event_loop()
. But these who need a new even loop already know this.
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.
new_event_loop is not correct, it should be asyncio.run or asyncio.Runner
Worst case it would be asyncio.EventLoop, new_event_loop uses the policy system
asyncio.get_event_loop
#126353