Replace asyncio.get_event_loop() with asyncio.get_running_loop() in coroutines

Proprietary

asyncio.get_event_loop() raises a RuntimeError in Python 3.14 where no event loop is set, rather than creating one. In the body of an async def, where a loop is always running, the call is replaced with asyncio.get_running_loop(). Elsewhere it is marked for review, as is a call through a name imported with from asyncio import get_event_loop.

org.openrewrite.python.migrate.ReplaceAsyncioGetEventLoop
mod run . --recipe=org.openrewrite.python.migrate.ReplaceAsyncioGetEventLoop

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.