{
  "id": "python/asyncio-task-exception-never-retrieved",
  "signature": "Task exception was never retrieved",
  "signature_zh": "任务异常从未被获取",
  "regex": "Task\\ exception\\ was\\ never\\ retrieved",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A Task raised an exception but nobody awaited it or called task.exception(). The default loop exception handler logs this warning at garbage collection.",
  "root_cause_type": "generic",
  "root_cause_zh": "某个 Task 抛出异常，但没有人 await 它或调用 task.exception()。默认事件循环异常处理器在垃圾回收时打印此警告。",
  "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"
    },
    {
      "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": "It's logged via loop.call_exception_handler, not the warnings module; the underlying failure persists.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The exception happens asynchronously inside the task, not at creation time.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "task = asyncio.create_task(worker())\ntask.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)\nawait task",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.93,
      "how": "results = await asyncio.gather(*tasks, return_exceptions=True)\nfor r in results:\n    if isinstance(r, Exception):\n        log.error('task failed', exc_info=r)",
      "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-02-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}