Skip to content

python.http_timeout

Stability High

Detects HTTP requests without timeout configuration.

Missing HTTP timeouts:

  • Requests hang forever — No timeout means indefinite wait
  • Resource exhaustion — Connections never released
  • Cascading failures — One slow service blocks everything
# ❌ Before (no timeout)
import httpx
async def fetch_data():
async with httpx.AsyncClient() as client:
return await client.get(url) # No timeout!
# ✅ After (with timeout)
import httpx
async def fetch_data():
async with httpx.AsyncClient(timeout=30.0) as client:
return await client.get(url)
# Or per-request timeout:
async def fetch_data():
async with httpx.AsyncClient() as client:
return await client.get(url, timeout=httpx.Timeout(30.0))
  • HTTP clients without timeout parameter
  • Per-request calls without timeout
  • Very long timeout values