{
  "id": "python/asyncio-timeout-context-manager-required",
  "signature": "TypeError: 'Timeout' object is not awaitable",
  "signature_zh": "TypeError: 'Timeout' 对象不可等待",
  "regex": "TypeError:\\ 'Timeout'\\ object\\ is\\ not\\ awaitable",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "In Python 3.11+, asyncio.timeout() returns an async context manager, not an awaitable. Code written for asyncio.wait_for or older patterns mistakenly awaits it.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 Python 3.11+ 中，asyncio.timeout() 返回异步上下文管理器，而不是可等待对象。为 asyncio.wait_for 或旧模式编写的代码错误地 await 了它。",
  "versions": [
    {
      "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": "Timeout is not callable; raises TypeError: 'Timeout' object is not callable.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "wait_for expects an awaitable; Timeout is a context manager, not awaitable.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "async with asyncio.timeout(5):\n    data = await fetch()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "try:\n    async with asyncio.timeout(5):\n        return await fetch()\nexcept AttributeError:\n    return await asyncio.wait_for(fetch(), timeout=5)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "import time\nloop = asyncio.get_running_loop()\ndeadline = loop.time() + 5\nasync with asyncio.timeout_at(deadline):\n    await fetch()",
      "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.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}