◐ Shell
clean mode source ↗

gh-93453: No longer create an event loop in get_event_loop() by serhiy-storchaka · Pull Request #98440 · python/cpython

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.

gvanrossum

gvanrossum

kumaraditya303

@serhiy-storchaka

gvanrossum

kumaraditya303

@ambv

@ambv

@ambv ambv mentioned this pull request

Dec 5, 2022

gvanrossum

@amotl amotl mentioned this pull request

Dec 12, 2022

p-gentili pushed a commit to canonical/yarf that referenced this pull request

Jun 1, 2026
…ction (#256)

The sync check_connection entrypoints in the Mir and Vnc platforms called asyncio.get_event_loop() to obtain (or implicitly create) an event loop. Since CPython PR python/cpython#98440 (Python 3.12), that call no longer auto-creates a loop once anything in the process has touched the loop policy and raises RuntimeError instead. With the recent pytest-asyncio 1.x and pytest 9 bumps, xdist workers no longer incidentally have a loop pre-installed.