Async Routes: When They Help, and When They Don't

An async def route that calls other services with httpx's AsyncClient can ask them all at once with asyncio.gather and give up after a timeout with a 503, while routes with blocking code such as sqlite3 stay plain def, because one blocking call inside async def holds up every request.

By

Updated

Cheat sheet: Async Routes: When They Help, and When They Don't
Category
FastAPI
Level
Freelancer
Tags
503 Service Unavailable, async def, Event Loop and Blocking Calls, fastapi, httpx, rest-api, Timeout (rest-api)