{
  "id": "python/asyncio-task-exception-was-never-retrieved",
  "signature": "Task exception was never retrieved\nfuture: <Task finished name='Task-5' coro=<fetch() done, defined at app.py:42> exception=ValueError('bad payload')>",
  "signature_zh": "任务异常从未被获取\nfuture: <Task finished name='Task-5' coro=<fetch() done, defined at app.py:42> exception=ValueError('bad payload')>",
  "regex": "Task\\ exception\\ was\\ never\\ retrieved\\\nfuture:\\ <Task\\ finished\\ name='Task\\-5'\\ coro=<fetch\\(\\)\\ done,\\ defined\\ at\\ app\\.py:42>\\ exception=ValueError\\('bad\\ payload'\\)>",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A task created with asyncio.create_task() raised an exception, but nobody awaited the task or called task.exception(), so the exception is logged as a warning at garbage collection.",
  "root_cause_type": "generic",
  "root_cause_zh": "使用 asyncio.create_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": "Hides the symptom but the task still fails silently and the error is lost.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Swallows real errors and produces no diagnostic; debugging becomes impossible.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "tasks = [asyncio.create_task(fetch(u)) for u in urls]\nresults = await asyncio.gather(*tasks, return_exceptions=True)\nfor r in results:\n    if isinstance(r, Exception):\n        logging.exception('task failed', exc_info=r)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.87,
      "how": "def _on_done(t: asyncio.Task):\n    if not t.cancelled() and t.exception():\n        logging.error('task error', exc_info=t.exception())\n\nt = asyncio.create_task(fetch(u))\nt.add_done_callback(_on_done)",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}