{
  "id": "python/asyncio-semaphore-timeout",
  "signature": "asyncio.exceptions.TimeoutError: semaphore could not be acquired within timeout",
  "signature_zh": "asyncio异常：在超时时间内无法获取信号量",
  "regex": "asyncio\\.exceptions\\.TimeoutError:\\ semaphore\\ could\\ not\\ be\\ acquired\\ within\\ timeout",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Using asyncio.wait_for() on a semaphore acquire() that times out due to high contention.",
  "root_cause_type": "generic",
  "root_cause_zh": "在高竞争情况下，对信号量acquire()使用asyncio.wait_for()导致超时。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "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": "",
      "why_fails": "May still fail under heavy load; doesn't address root cause.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Leads to resource exhaustion and potential system instability.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "async with asyncio.timeout(5): await sem.acquire()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "for i in range(3): try: await asyncio.wait_for(sem.acquire(), 1); break except TimeoutError: pass",
      "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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}