Skip to content
Discussion options

You must be logged in to vote

Is it okay to override sync dependencies with async ones?

There is no problem with that. FastAPI will see that this function is sync and run it in the thread_pool.

Does fastapi add sync dependencies in executor mode from asyncio or it just plain use them?

Sync dependencies will be executed in separate thread and will not block the event loop.

If your dependency function is not a heavy CPU task, just use async to define it

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mr-mapache
Comment options

Answer selected by mr-mapache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants