python
runtime_error
ai_generated
true
RuntimeWarning: 协程 'get_data' 从未被 await
RuntimeWarning: coroutine 'get_data' was never awaited
ID: python/fastapi-await-missing
80%修复率
89%置信度
0证据数
2024-07-29首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
在异步路由中调用异步函数时未使用 await,导致返回协程对象而非数据。
English
An async function was called without await inside an async route, so the coroutine object was returned instead of data.
解决方案
-
95% 成功率
data = await get_data()
-
85% 成功率
Make route sync def and call sync version of helper
无效尝试
常见但无效的做法:
-
85% 失败
Cannot run event loop inside a running loop; raises RuntimeError.
-
80% 失败
Silences signal but response body is still a coroutine.