{
  "id": "python/asyncio-queue-get-timeout",
  "signature": "asyncio.exceptions.TimeoutError: Queue get timed out",
  "signature_zh": "asyncio 异常：队列获取超时",
  "regex": "asyncio\\.exceptions\\.TimeoutError:\\ Queue\\ get\\ timed\\ out",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "An asyncio.Queue.get() call with a timeout did not receive an item within the specified time.",
  "root_cause_type": "generic",
  "root_cause_zh": "带超时的 asyncio.Queue.get() 调用在指定时间内未收到项目。",
  "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 a very large timeout to avoid the error",
      "why_fails": "This may cause the application to hang if items are never produced.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    },
    {
      "action": "Polling the queue with qsize() before get()",
      "why_fails": "qsize() is not reliable in concurrent scenarios due to race conditions.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use asyncio.wait_for() with a reasonable timeout and handle timeout gracefully",
      "success_rate": 0.9,
      "how": "try:\n    item = await asyncio.wait_for(queue.get(), timeout=5.0)\nexcept asyncio.TimeoutError:\n    item = None  # or handle differently",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use queue.get_nowait() in a loop with sleep",
      "success_rate": 0.8,
      "how": "while True:\n    try:\n        item = queue.get_nowait()\n        break\n    except asyncio.QueueEmpty:\n        await asyncio.sleep(0.1)",
      "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-04-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}