{
  "id": "python/fastapi-async-blocking-event-loop",
  "signature": "RuntimeWarning: coroutine 'sleep' was never awaited / requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))",
  "signature_zh": "RuntimeWarning: 协程 'sleep' 从未被等待 / requests.exceptions.ConnectionError: ('连接中止。', RemoteDisconnected('远程端关闭连接而未响应'))",
  "regex": "RuntimeWarning:\\ coroutine\\ 'sleep'\\ was\\ never\\ awaited\\ /\\ requests\\.exceptions\\.ConnectionError:\\ \\('Connection\\ aborted\\.',\\ RemoteDisconnected\\('Remote\\ end\\ closed\\ connection\\ without\\ response'\\)\\)",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Blocking synchronous calls (requests, time.sleep, heavy IO) inside an async def endpoint block the event loop, causing timeouts and dropped connections.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 async def 端点内进行阻塞式同步调用（requests、time.sleep、重 IO）会阻塞事件循环，导致超时和连接中断。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Does not unblock the event loop; requests still queue.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Each worker still has one blocked loop; capacity is limited.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "import httpx\nasync with httpx.AsyncClient() as client:\n    r = await client.get(url)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from starlette.concurrency import run_in_threadpool\nresult = await run_in_threadpool(blocking_fn, arg)",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}