Skip to content

Controlling and understanding parallel requests #87

Answered by br3ndonland
bodograumann asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for sharing some insights on this. Concurrency can be difficult to understand and control.

There is a vital difference between using def and async def for endpoints in FastAPI.

Yes, definitely. I think it's summarized well in the post you shared:

Note that async does not mean parallel, but concurrently. Asynchronous code with async and await is many times summarised as using coroutines. Coroutines are collaborative (or cooperatively multitasked), meaning that "at any given time, a program with coroutines is running only one of its coroutines, and this running coroutine suspends its execution only when it explicitly requests to be suspended" (see here and here for more info on…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

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