Home / Function/ add_task() — fastapi Function Reference

add_task() — fastapi Function Reference

Architecture documentation for the add_task() function in background.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  6dae3f2e_5480_40c7_b356_110ad2700aeb["add_task()"]
  dc716d57_75c7_1136_7c80_2b5bb5ee95ab["BackgroundTasks"]
  6dae3f2e_5480_40c7_b356_110ad2700aeb -->|defined in| dc716d57_75c7_1136_7c80_2b5bb5ee95ab
  style 6dae3f2e_5480_40c7_b356_110ad2700aeb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/background.py lines 39–60

    def add_task(
        self,
        func: Annotated[
            Callable[P, Any],
            Doc(
                """
                The function to call after the response is sent.

                It can be a regular `def` function or an `async def` function.
                """
            ),
        ],
        *args: P.args,
        **kwargs: P.kwargs,
    ) -> None:
        """
        Add a function to be called in the background after the response is sent.

        Read more about it in the
        [FastAPI docs for Background Tasks](https://fastapi.tiangolo.com/tutorial/background-tasks/).
        """
        return super().add_task(func, *args, **kwargs)

Domain

Subdomains

Frequently Asked Questions

What does add_task() do?
add_task() is a function in the fastapi codebase, defined in fastapi/background.py.
Where is add_task() defined?
add_task() is defined in fastapi/background.py at line 39.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free