Replies: 2 comments 2 replies
-
Can you create a minimal code example that we can run and see the behavior you mentioned? |
Beta Was this translation helpful? Give feedback.
-
Hello, i have been trying to replicate it but i am facing some troubles. After trying some things i noticed that the request isnt run during the request but after, so the background tasks work but the frontend waits in a way till after the background task finishes running before cutting the connection. Here are some logs: I timed the time each call takes, so the frontend keeps the request as "ongoing" in a way i.e wont close connection or something until the generator finishes then it will close. NOTE: the generator is an async function that calls a bunch of other async functions and it also has a couple of loops |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
When the above endpoint is called, it runs the background tasks before the response is set.
However when i declare a vaiable i.e.
response = {"data": await format_validator()}
it will work normally then return that, it will then work properly.NOTE: i saw that the logs in the background tasks only appear after the logs show
/validator 200 OK
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.111.0
Pydantic Version
2.7.1
Python Version
3.12.4
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions