# RuntimeWarning: 协程 'foo' 从未被 await

- **ID:** `python/asyncio-coroutine-was-never-awaited`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

调用了协程函数但返回的协程对象从未被 await 或调度，通常是因为忘记 await 或将其传给了非异步 API。

## 版本兼容性

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

## 解决方案

1. **** (98% 成功率)
   ```
   Add the missing await:

async def main():
    result = await foo()  # was: foo()
   ```
2. **** (90% 成功率)
   ```
   If you only want to schedule it, wrap with asyncio.create_task():

asyncio.create_task(foo())
   ```

## 无效尝试

- **** — Hides the symptom while the coroutine body never executes, causing silent data loss and downstream bugs. (95% 失败率)
- **** — Raises RuntimeError: asyncio.run() cannot be called from a running event loop. (85% 失败率)
