{
  "id": "python/asyncio-future-invalid-state",
  "signature": "asyncio.exceptions.InvalidStateError: Future is already resolved",
  "signature_zh": "asyncio 异常：Future 已解决",
  "regex": "asyncio\\.exceptions\\.InvalidStateError:\\ Future\\ is\\ already\\ resolved",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempting to set a result or exception on a Future that has already been resolved (completed or cancelled).",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试在已解决（已完成或已取消）的 Future 上设置结果或异常。",
  "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Checking if the future is done before setting result",
      "why_fails": "If done, setting result is still invalid; this may cause the error if not handled properly.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a new Future for each operation",
      "why_fails": "This may lead to resource leaks if old futures are not cleaned up.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check if the future is done before setting result",
      "success_rate": 0.9,
      "how": "if not future.done():\n    future.set_result(value)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use asyncio.Future with proper lifecycle management",
      "success_rate": 0.85,
      "how": "future = asyncio.get_event_loop().create_future()\n# ensure only one set_result call",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-12-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}