{
  "id": "python/asyncio-cannot-run-coroutine-already-running",
  "signature": "RuntimeError: cannot reuse already awaited coroutine",
  "signature_zh": "RuntimeError: 无法复用已经 await 过的协程",
  "regex": "RuntimeError:\\ cannot\\ reuse\\ already\\ awaited\\ coroutine",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A coroutine object was awaited more than once. Coroutines in Python are single-shot; reusing the same coroutine object (e.g., in a retry loop or cached in a variable) raises this error.",
  "root_cause_type": "generic",
  "root_cause_zh": "同一个协程对象被 await 了多次。Python 中的协程是一次性的；在重试循环中复用同一个协程对象或将其缓存到变量后重复 await 都会触发此错误。",
  "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": "The coroutine frame is exhausted; send raises StopIteration immediately.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Shallow copy shares the same frame; awaiting the copy raises the same error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "async def fetch(): ...\nfor _ in range(3):\n    await fetch()   # new coroutine each iteration",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "task = asyncio.ensure_future(fetch())\nawait task\nawait task   # Tasks can be awaited multiple times",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "from functools import partial\nmake = partial(fetch, url)\nawait make()\nawait make()",
      "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-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}