{
  "id": "python/asyncio-loop-policy-deprecated",
  "signature": "DeprecationWarning: There is no current event loop",
  "signature_zh": "DeprecationWarning: 没有当前事件循环",
  "regex": "DeprecationWarning:\\ There\\ is\\ no\\ current\\ event\\ loop",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "asyncio.get_event_loop() was called with no running loop and no loop set for the current thread; Python 3.10+ deprecates this behavior and 3.12+ warns.",
  "root_cause_type": "generic",
  "root_cause_zh": "在没有运行循环且当前线程未设置循环的情况下调用了 asyncio.get_event_loop()；Python 3.10+ 弃用此行为，3.12+ 发出警告。",
  "versions": [
    {
      "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 warning but the underlying API will be removed in 3.14.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Creates a loop that is never closed; leaks resources and causes 'loop is closed' errors later.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Not a maintainable fix; 3.9 is EOL in Oct 2025.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Inside async code, use asyncio.get_running_loop():\n\nloop = asyncio.get_running_loop()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "From sync code, use asyncio.new_event_loop() and manage lifetime explicitly:\n\nloop = asyncio.new_event_loop()\ntry:\n    loop.run_until_complete(coro())\nfinally:\n    loop.close()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "Use asyncio.Runner (3.11+) for repeated runs:\n\nwith asyncio.Runner() as runner:\n    runner.run(coro())",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}