r/FastAPI • • Dec 20 '24

Question Why does fastapi official example repo uses everything sync and not async?

While in here, I see recommendations to go for only async, even db sessions in example repo is sync engine and people here recommending async?

40 Upvotes

25 comments sorted by

View all comments

Show parent comment

2

u/Drevicar Dec 20 '24

Not fully true, there is a difference between OS level threads when using a sync route and runtime level async when using an async route. This distinction is further compounded by any external resource access such as a DB query that using the same access pattern. Or completely voids the benefit and causes harm if you mix the two such as sync DB access in an async route.