{
  "id": "python/fastapi-depends-async-generator-not-closed",
  "signature": "RuntimeWarning: coroutine 'get_db' was never awaited",
  "signature_zh": "RuntimeWarning: 协程 'get_db' 从未被 await",
  "regex": "RuntimeWarning:\\ coroutine\\ 'get_db'\\ was\\ never\\ awaited",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "An async dependency (async def or async generator) is used as a plain function, or Depends is missing so the coroutine is returned unawaited.",
  "root_cause_type": "generic",
  "root_cause_zh": "异步依赖（async def 或异步生成器）被当作普通函数使用，或漏写 Depends 导致返回未 await 的协程。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Blocks the event loop and may break async DB drivers.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Returns a coroutine/generator you then misuse; resources leak.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "Declare the dependency with Depends:\ndef route(db=Depends(get_db)): ...",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "Use an async generator dependency that yields and cleans up in finally.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-03-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}