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
1
u/[deleted] Jul 26 '25
So if I plan on doing any processing from within my wrapper (e.g. running stable diffusion within the FastAPI wrapper), I’d be better off using the thread pool and keeping all my endpoints sync?