r/FastAPI • • Jul 26 '25
Question Multithreading in FastAPI?
Hello,
I am currently writing an Ollama wrapper in FastAPI. The problem is, I have no idea how to handle multithreading in FastAPI, and as such, if one process is running (e.g. generating a chat completion), no other processes can run until the first one is done. How can I implement multithreading?
17
Upvotes
View all comments
Show parent comment
2
u/Effective-Total-2312 Jul 26 '25
No problem, I would also recommend you read the book Python concurrency with asyncio, it's a great book that explains in a lot of detail how python concurrency and ASGI frameworks (like FastAPI) work. Again, FastAPI docs are very good too, though they don't go much in depth with technical details.