Skip to content

python.http_blocking_async

Performance High

Detects blocking HTTP calls in async code.

Blocking HTTP in async:

  • Event loop blocked — All other tasks stall
  • Concurrency destroyed — Async benefits lost
  • Timeout cascades — Other coroutines time out
# ❌ Before (blocking call in async)
import requests
async def fetch_data():
response = requests.get(url) # Blocks event loop!
return response.json()
# ✅ After (async HTTP client)
import httpx
async def fetch_data():
async with httpx.AsyncClient() as client:
response = await client.get(url)
return response.json()
  • requests.get/post in async functions
  • urllib calls in async context
  • Sync HTTP clients in coroutines