{
  "id": "python/asyncio-cannot-reuse-already-awaited-coroutine",
  "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 once and then awaited again. Coroutine objects are single-use; each call to a coroutine function yields a fresh coroutine.",
  "root_cause_type": "generic",
  "root_cause_zh": "协程对象被 await 一次后再次 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 state is exhausted; send raises StopIteration immediately.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The coroutine object is already closed; ensure_future raises the same error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.97,
      "how": "# Wrong\nc = fetch(url)\nawait c\nawait c\n# Right\nawait fetch(url)\nawait fetch(url)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "task = asyncio.create_task(fetch(url))\nawait task\nawait task  # Tasks are awaitable multiple times",
      "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-04-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}