{
  "id": "python/coroutine-never-awaited",
  "signature": "RuntimeWarning: coroutine 'fetch_data' was never awaited",
  "signature_zh": "RuntimeWarning: 协程 'fetch_data' 从未被 await",
  "regex": "RuntimeWarning:\\ coroutine\\ 'fetch_data'\\ was\\ never\\ awaited",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A coroutine function was called without await or asyncio.create_task, so the coroutine object was created and garbage collected without running.",
  "root_cause_type": "generic",
  "root_cause_zh": "调用了一个协程函数但没有 await 或 asyncio.create_task，因此创建了协程对象并在未运行的情况下被垃圾回收。",
  "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; the async work silently never runs.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Raises 'asyncio.run() cannot be called from a running event loop'.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Breaks other callers and loses concurrency.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Await the coroutine in an async context:\n\nasync def main():\n    data = await fetch_data()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "If you intentionally want fire-and-forget, schedule it:\n\nasyncio.create_task(fetch_data())",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "Enable -W error::RuntimeWarning in tests to catch this at CI time.",
      "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-02-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}