# RuntimeError: Session is closed

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

## Root Cause

An aiohttp.ClientSession was used after being closed, typically because it was created in an async with block that exited, or the session attribute was reused across requests after aclose().

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   session = aiohttp.ClientSession()
try:
    await session.get(url)
finally:
    await session.close()
   ```
2. **** (92% success)
   ```
   async with aiohttp.ClientSession() as session:
    async with session.get(url) as resp:
        data = await resp.text()
   ```

## Dead Ends

- **** — The old session object is still closed; reassigning may leave background connectors attached to the closed session. (70% fail)
- **** — The session is closed, not slow; the request cannot even be queued. (90% fail)
