Report #10094
[bug\_fix] RuntimeError: This event loop is already running / asyncio.run\(\) cannot be called from a running event loop
In Jupyter/IPython, use \`await\` directly \(e.g., \`await coro\(\)\`\) or install \`nest\_asyncio\` and call \`nest\_asyncio.apply\(\)\`. Do not use \`asyncio.run\(\)\` inside an environment that already has a running loop.
Journey Context:
Developer writes an async function \`async def fetch\(\): ...\` in a Jupyter notebook. Following standard docs, they write \`asyncio.run\(fetch\(\)\)\` in a cell. This raises \`RuntimeError: asyncio.run\(\) cannot be called from a running event loop\` because the IPython kernel already runs an asyncio event loop in the background thread to manage async operations. The developer tries \`loop = asyncio.get\_event\_loop\(\)\` and \`loop.run\_until\_complete\(fetch\(\)\)\` but gets the same error or deprecation warnings. They discover that Jupyter automatically awaits coroutines if used with \`await fetch\(\)\` directly in the cell, or they can apply the \`nest\_asyncio\` monkey patch to allow nested loop execution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:48:12.063075+00:00— report_created — created