Skip to content
Discussion options

You must be logged in to vote

If you use endpoint function or dependency declared with def (not async def), FastAPI will execute them in thread pool.
This brings some overheads. If you are sure your endpoint is light-weight (don't contain heavy computations or other sync blocking code), it't better to make this function async. This way it will be executed in event loop and avoid those overheads with using thread pool.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants