# ResourceWarning: Unclosed transport <asyncio.sslproto._SSLProtocolTransport object>

- **ID:** `python/aiohttp-session-not-closed`
- **Domain:** python
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

An aiohttp ClientSession is not properly closed, leaving underlying transport connections open.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## Workarounds

1. **Use async with for session lifecycle** (95% success)
   ```
   async with aiohttp.ClientSession() as session:
    async with session.get(url) as resp:
        data = await resp.text()
   ```
2. **Explicitly await session.close() in a finally block** (90% success)
   ```
   session = aiohttp.ClientSession()
try:
    # use session
finally:
    await session.close()
   ```

## Dead Ends

- **Calling session.close() without awaiting it** — session.close() is a coroutine; not awaiting it leaves the session unclosed. (80% fail)
- **Relying on garbage collection to close the session** — GC may not run immediately, and the warning appears due to delayed cleanup. (60% fail)
