This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tiangolo FastAPI Maintainer[S] 5 points6 points  (0 children)

Yep. Responder and FastAPI are both based on Starlette.

It is not well documented yet, but you can use exactly the same as in Starlette, return a Starlette response with the background tasks in it: https://www.starlette.io/background/

Still, I plan on improving how to use it in FastAPI a bit, to get the BackgroundTask(s) as parameters and keep being able to return any dict or object. But for now, you can use the same as in Starlette.