Skip to content

Clarification regarding a point mentioned in FastAPI's Async Documentation #10771

Discussion options

You must be logged in to vote

FastAPI is an async framework, and async should the be the default choice.

Really the threadpool def endpoints are an escape hatch for running sync/blocking code because the python async ecosystem is still pretty nascent (and sometimes you just need to run blocking code).

There is also the problem of function coloring. You cannot as easily run an async function ( which should be the majority of your functions) inside a def function.

You also take a performance hit spawning the request to a thread pool.

Anyway I agree that the docs there are worded a bit awkwardly and should probably say something like "If you don't have any blocking IO or CPU bound code you should use async" but they are …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Kludex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants