1

FastAPI is powered by Starlette which is asynchronous. But I can write functions for routes in FastAPI both synchronously and asynchronously. How much worse will synchronous functions work for a regular site API than asynchronous ones? And if I write synchronous functions, then the api will still work asynchronously? And also if you mix approaches, then make the database asynchronous? And do the initialization of the server itself synchronous?

Dronikon
  • 31
  • 5
  • Some background on mixing [sync and async](https://stackoverflow.com/questions/54323525/mixing-synchronous-and-a-sync-code-in-python). – metatoaster May 30 '23 at 06:48
  • @metatoaster how bad will it be if I will use only sync code? – Dronikon May 30 '23 at 06:55
  • @Dronikon your requests will run in an internal threadpool in FastAPI. Whether that will be bad will depend on what your code is doing and your exact use case. Test it. – MatsLindh May 30 '23 at 10:02

0 Answers0