# RuntimeError: asyncio.run() cannot be called from a running event loop

- **ID:** `python/asyncio-run-called-from-running-loop`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

asyncio.run() is invoked from inside an already-running event loop, e.g. calling it in a Jupyter notebook cell or from within an async function.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   # in a Jupyter cell
result = await main()  # top-level await, no asyncio.run
   ```
2. **** (85% success)
   ```
   import threading, asyncio
result = {}
def _run():
    result['v'] = asyncio.run(main())
t = threading.Thread(target=_run); t.start(); t.join()
   ```

## Dead Ends

- **** — Raises the same error because the loop is already running. (90% fail)
- **** — Works only if you create a fresh loop in that thread; otherwise you get 'no running event loop'. (70% fail)
