News
FastAPI 0.163's new dependency concurrency limit deadlocked two of my routes
DEV · By Alex Georgiev ·
The Brief
- A developer reports that two FastAPI 0.163 routes deadlocked when each used a dependency capped to one concurrent user with the new max_concurrency option.
- One route acquired shared resource A then B, while the other acquired B then A.
- Firing one request at each route at the same time caused the deadlock, according to the post.
Why it matters
Dependencies limited with max_concurrency can hang routes when they acquire multiple shared resources in conflicting orders, so apps using this option should test concurrent requests.
Who’s affected
- Teams using FastAPI 0.163 max_concurrency on dependencies
- FastAPI 0.163
- #fastapi
- #python
- #concurrency
- #deadlock
- #dependencies
Two routes in my test app each took one dependency that managed a shared resource, each capped to one concurrent user with FastAPI's new max_concurrency option. One route asked for resource A then resource B. The other asked for B then A. I fired one request at each at the same…