Closed rafelpermata closed 1 year ago
I assume anyio
is another package that provides the run_sync
function? In that case, I would rather not add a complete package just for the sake of one function. If the same functionality can be achieved with the current dependencies or the standard library, I will gladly merge the changes.
I assume
anyio
is another package that provides therun_sync
function? In that case, I would rather not add a complete package just for the sake of one function. If the same functionality can be achieved with the current dependencies or the standard library, I will gladly merge the changes.
Hi, fastapi is based on anyio, so I think it is no problem to use it https://fastapi.tiangolo.com/async/#write-your-own-async-code
FastAPI does not seem to explicitly depend on AnyIO see here. I have decided however to add the dependency to ensure that, in the case fastapi decides to stop using AnyIO no issues will occur. Thanks for creating the PR.
Hi, if user loader is using sync db connection and the
def
function, it will run in the main thread and block the main thread from receiving any request. So it thedef
function should be run in worker thread instead.