Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`.)
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor

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



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)

async def func():
self.assertIs(asyncio.get_event_loop(), loop)
self.assertIs(asyncio.get_running_loop(), loop)
self.assertIs(asyncio._get_running_loop(), loop)

loop.run_until_complete(func())

Expand Down
Loading