0

I implemented my simple server on Python and FastAPI and currently learn more about async / await work in FastAPI. The question is based on this doc and it is unclear does async calls go to a thread pool or not.

I am familiar with concept of coroutines by extensively using them in Kotlin / Android. In this context coroutines are organised in some state machine and there is no usage of the thread pool. Is it the same in Python / FastApi?

Gleichmut
  • 5,953
  • 5
  • 24
  • 32

1 Answers1

1

From the docs you linked, it appears that async things run on a single even loop (non-threaded) and sync things run on a thread pool. This makes sense since the async paradigm is single threaded by design (in python anyway).

I remind you that in python threads are not concurrent, so there won't be a performance boost from using a pool for async operations since they happen one at a time anyway

Nullman
  • 4,179
  • 2
  • 14
  • 30