python runtime_error ai_generated true

RuntimeWarning: coroutine 'get_data' was never awaited

ID: python/fastapi-await-missing

Also available as: JSON · Markdown · 中文
80%Fix Rate
89%Confidence
0Evidence
2024-07-29First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

An async function was called without await inside an async route, so the coroutine object was returned instead of data.

generic

中文

在异步路由中调用异步函数时未使用 await,导致返回协程对象而非数据。

Workarounds

  1. 95% success
    data = await get_data()
  2. 85% success
    Make route sync def and call sync version of helper

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Cannot run event loop inside a running loop; raises RuntimeError.

  2. 80% fail

    Silences signal but response body is still a coroutine.