{
  "id": "python/asyncio-coroutine-was-never-awaited",
  "signature": "RuntimeWarning: coroutine 'foo' was never awaited",
  "signature_zh": "RuntimeWarning: 协程 'foo' 从未被 await",
  "regex": "RuntimeWarning:\\ coroutine\\ 'foo'\\ was\\ never\\ awaited",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A coroutine function was called but the returned coroutine object was never awaited or scheduled, usually by forgetting await or passing it to a non-async API.",
  "root_cause_type": "generic",
  "root_cause_zh": "调用了协程函数但返回的协程对象从未被 await 或调度，通常是因为忘记 await 或将其传给了非异步 API。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Hides the symptom while the coroutine body never executes, causing silent data loss and downstream bugs.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Raises RuntimeError: asyncio.run() cannot be called from a running event loop.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "Add the missing await:\n\nasync def main():\n    result = await foo()  # was: foo()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "If you only want to schedule it, wrap with asyncio.create_task():\n\nasyncio.create_task(foo())",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}