{
  "id": "python/aiohttp-session-not-closed",
  "signature": "ResourceWarning: Unclosed transport <asyncio.sslproto._SSLProtocolTransport object>",
  "signature_zh": "资源警告：未关闭的传输对象",
  "regex": "ResourceWarning:\\ Unclosed\\ transport\\ <asyncio\\.sslproto\\._SSLProtocolTransport\\ object>",
  "domain": "python",
  "category": "system_error",
  "subcategory": null,
  "root_cause": "An aiohttp ClientSession is not properly closed, leaving underlying transport connections open.",
  "root_cause_type": "generic",
  "root_cause_zh": "aiohttp 的 ClientSession 未正确关闭，导致底层传输连接保持打开状态。",
  "versions": [
    {
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Calling session.close() without awaiting it",
      "why_fails": "session.close() is a coroutine; not awaiting it leaves the session unclosed.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Relying on garbage collection to close the session",
      "why_fails": "GC may not run immediately, and the warning appears due to delayed cleanup.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use async with for session lifecycle",
      "success_rate": 0.95,
      "how": "async with aiohttp.ClientSession() as session:\n    async with session.get(url) as resp:\n        data = await resp.text()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Explicitly await session.close() in a finally block",
      "success_rate": 0.9,
      "how": "session = aiohttp.ClientSession()\ntry:\n    # use session\nfinally:\n    await session.close()",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}