{
  "id": "python/asyncio-runner-not-found",
  "signature": "RuntimeError: asyncio.run() cannot be called from a running event loop",
  "signature_zh": "运行时错误：不能从正在运行的事件循环中调用 asyncio.run()",
  "regex": "RuntimeError:\\ asyncio\\.run\\(\\)\\ cannot\\ be\\ called\\ from\\ a\\ running\\ event\\ loop",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "asyncio.run() is called inside an async function where an event loop is already running, causing a nested loop conflict.",
  "root_cause_type": "generic",
  "root_cause_zh": "在异步函数内部调用 asyncio.run()，此时事件循环已在运行，导致嵌套循环冲突。",
  "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using asyncio.get_event_loop().run_until_complete() instead",
      "why_fails": "This still tries to run a new loop inside an existing one, leading to the same error.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrapping the call in a thread to avoid loop conflict",
      "why_fails": "asyncio.run() still needs a loop; running in a thread without proper loop setup may cause other issues.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use await directly instead of asyncio.run()",
      "success_rate": 0.95,
      "how": "await some_coroutine()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use asyncio.create_task() to schedule the coroutine",
      "success_rate": 0.9,
      "how": "task = asyncio.create_task(some_coroutine())\nawait task",
      "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-06-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}