# 运行时错误：不能从正在运行的事件循环中调用 asyncio.run()

- **ID:** `python/asyncio-runner-not-found`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在异步函数内部调用 asyncio.run()，此时事件循环已在运行，导致嵌套循环冲突。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## 解决方案

1. **Use await directly instead of asyncio.run()** (95% 成功率)
   ```
   await some_coroutine()
   ```
2. **Use asyncio.create_task() to schedule the coroutine** (90% 成功率)
   ```
   task = asyncio.create_task(some_coroutine())
await task
   ```

## 无效尝试

- **Using asyncio.get_event_loop().run_until_complete() instead** — This still tries to run a new loop inside an existing one, leading to the same error. (70% 失败率)
- **Wrapping the call in a thread to avoid loop conflict** — asyncio.run() still needs a loop; running in a thread without proper loop setup may cause other issues. (50% 失败率)
