]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-93453: No longer create an event loop in get_event_loop() (#98440)
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 6 Dec 2022 17:42:12 +0000 (19:42 +0200)
committerGitHub <noreply@github.com>
Tue, 6 Dec 2022 17:42:12 +0000 (18:42 +0100)
commitfd38a2f0ec03b4eec5e3cfd41241d198b1ee555a
treef5019c34b08ec4dbfcbcd95edbde05553d283481
parentb72014c783e5698beb18ee1249597e510b8bcb5a
gh-93453: No longer create an event loop in get_event_loop() (#98440)

asyncio.get_event_loop() now always return either running event loop or
the result of get_event_loop_policy().get_event_loop() call. The latter
should now raise an RuntimeError if no current event loop was set
instead of creating and setting a new event loop.

It affects also a number of asyncio functions and constructors which
call get_event_loop() implicitly: ensure_future(), shield(), gather(),
etc.

DeprecationWarning is no longer emitted if there is no running event loop but
the current event loop was set.

Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
18 files changed:
Doc/library/asyncio-eventloop.rst
Doc/library/asyncio-llapi-index.rst
Doc/library/asyncio-policy.rst
Doc/whatsnew/3.12.rst
Lib/asyncio/events.py
Lib/asyncio/futures.py
Lib/asyncio/streams.py
Lib/asyncio/tasks.py
Lib/test/test_asyncio/test_base_events.py
Lib/test/test_asyncio/test_events.py
Lib/test/test_asyncio/test_futures.py
Lib/test/test_asyncio/test_streams.py
Lib/test/test_asyncio/test_tasks.py
Lib/test/test_asyncio/test_unix_events.py
Lib/test/test_coroutines.py
Misc/NEWS.d/next/Library/2022-10-19-13-37-23.gh-issue-93453.wTB_sH.rst [new file with mode: 0644]
Modules/_asynciomodule.c
Modules/clinic/_asynciomodule.c.h