{
  "id": "python/asyncio-event-loop-call-later-error",
  "signature": "RuntimeError: Event loop is closed: call_soon() cannot be called",
  "signature_zh": "运行时错误：事件循环已关闭：无法调用 call_soon()",
  "regex": "RuntimeError:\\ Event\\ loop\\ is\\ closed:\\ call_soon\\(\\)\\ cannot\\ be\\ called",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A callback is scheduled on an event loop that has already been closed, often after asyncio.run() finishes.",
  "root_cause_type": "generic",
  "root_cause_zh": "在已关闭的事件循环上调度回调，通常在 asyncio.run() 完成后发生。",
  "versions": [
    {
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using asyncio.get_event_loop() to get a new loop",
      "why_fails": "If the loop is closed, get_event_loop() may raise an error or return a closed loop.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignoring the error and assuming the callback ran",
      "why_fails": "The callback never executes, leading to incomplete operations.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure all callbacks are scheduled before the loop closes",
      "success_rate": 0.85,
      "how": "loop = asyncio.get_running_loop()\nloop.call_soon(some_callback)\n# ensure loop is still running",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use asyncio.get_running_loop() to check if loop is active",
      "success_rate": 0.9,
      "how": "try:\n    loop = asyncio.get_running_loop()\n    loop.call_soon(callback)\nexcept RuntimeError:\n    # loop not running, handle accordingly",
      "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-08-30",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}