Skip to content
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

Merged
merged 11 commits into from
Nov 4, 2024
2 changes: 1 addition & 1 deletion Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ an event loop:
event loop.

.. versionchanged:: 3.14
Raises a :exc:`RuntimeError` if there is no set event loop.
Raises a :exc:`RuntimeError` if there is no current event loop.

.. function:: set_event_loop(loop)

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ 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 set event loop.
It now raises a :exc:`RuntimeError` if there is no current event loop.
(Contributed by Kumar Aditya in :gh:`126353`.)


Expand Down
6 changes: 2 additions & 4 deletions Lib/test/test_asyncio/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2905,14 +2905,12 @@ def test_get_event_loop_returns_running_loop2(self):
asyncio.get_event_loop()

asyncio.set_event_loop(None)
with self.assertRaisesRegex(RuntimeError, 'no running'):
asyncio.get_running_loop()
with self.assertRaisesRegex(RuntimeError, 'no current'):
asyncio.get_event_loop()
self.assertIs(asyncio._get_running_loop(), None)
kumaraditya303 marked this conversation as resolved.
Show resolved Hide resolved

async def func():
self.assertIs(asyncio.get_event_loop(), loop)
self.assertIs(asyncio.get_running_loop(), loop)
self.assertIs(asyncio._get_running_loop(), loop)
kumaraditya303 marked this conversation as resolved.
Show resolved Hide resolved

loop.run_until_complete(func())

Expand Down
Loading