python.async_resource_cleanup
Stability
High
Detects async resources not properly cleaned up.
Why It Matters
Section titled “Why It Matters”Leaked async resources:
- Connection leaks — Clients/sockets not closed
- Resource exhaustion — File descriptors run out
- Memory leaks — Objects never garbage collected
Example
Section titled “Example”# ❌ Before (resource not cleaned up)async def fetch_data(): client = httpx.AsyncClient() response = await client.get(url) return response.json() # Client never closed!# ✅ After (proper cleanup with async context manager)async def fetch_data(): async with httpx.AsyncClient() as client: response = await client.get(url) return response.json() # Client automatically closedWhat Unfault Detects
Section titled “What Unfault Detects”- AsyncClient without async context manager
- aiofiles.open without async with
- Database connections not closed