Background Tasks + Templates Best Practice #2886
Replies: 1 comment
-
The answer was to not use starlette. Just create a separate python docker container to get background tasks done. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Similarly to the question raised re StreamingResponse + Templates Best Practice #2868
I am trying to add a background task while using TemplateResponse.
According to the docs for Background Tasks, A Background Tasks will run only once the response has been sent. Docs here: https://www.starlette.io/background/ This works with
JSONResponse(message, background=task)
as per the example, but doesn't seem to with TemplateResponse.I checked the Responses docs and there is no mention of
background=
at all for any Responses. Docs here: https://www.starlette.io/responses/Is there any documentation at all surrounding
background=
and what options are available for TemplateResponse?Ideally, I'd love to know if I'm doing something wrong with TemplateResponse that is causing both Background Tasks and StreamingResponse to not work. Or if it's a limitation of TemplateResponse.
Beta Was this translation helpful? Give feedback.
All reactions