Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Use def in FastAPI dashboard calls. #222

Merged
merged 1 commit into from
Dec 9, 2024
Merged

Conversation

aponcedeleonch
Copy link
Contributor

Quote from FastAPI docs

Path operation functions
When you declare a path operation function with normal def instead of async def, it is run in an external threadpool that is then awaited, instead of being called directly (as it would block the server).

What we have experienced in Trusty is that if we use async def it will queue the requests and wait for them sequentially (blocking the server). While using just def will not block the server as the requests are run in a threadpool. This PR uses def in the dashboard functions to not affect User Experience blocking the dashboard.

Quote from [FastAPI docs](https://fastapi.tiangolo.com/async/#path-operation-functions)
> Path operation functions
When you declare a path operation function with normal def instead of async def, it is run in an external threadpool that is then awaited, instead of being called directly (as it would block the server).

What we have experienced in Trusty is that if we use `async def` it will queue the requests and wait for them sequentially. While using just `def` will not block the server. This PR used `def` in the dashboard functions to not affect User Experience.
@aponcedeleonch aponcedeleonch merged commit ab91b29 into main Dec 9, 2024
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants