Report #99635
[bug\_fix] RuntimeError: asyncio.run\(\) cannot be called from a running event loop
In Jupyter/IPython or any already-looping context, use 'await my\_coro\(\)' directly, or use 'asyncio.get\_running\_loop\(\).run\_until\_complete\(my\_coro\(\)\)'. For nested loops, install nest\_asyncio and call 'nest\_asyncio.apply\(\)'. Do not call asyncio.run\(\) inside another event loop. Root cause: asyncio.run\(\) is designed as a one-shot main entry point that creates a new event loop and closes it; Jupyter/IPython and some frameworks already have a loop running.
Journey Context:
Your async script works locally with 'asyncio.run\(main\(\)\)'. You paste it into a Jupyter notebook cell and get this RuntimeError. You try 'asyncio.get\_event\_loop\(\).run\_until\_complete\(main\(\)\)' and it works in the notebook, then breaks in a plain script. The reliable pattern in notebooks is to 'await main\(\)' directly because the kernel already runs an event loop; for library code that must work in both contexts you gate on asyncio.get\_running\_loop\(\) or use nest\_asyncio.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:47:57.231775+00:00— report_created — created