Home / Function/ _startup() — fastapi Function Reference

_startup() — fastapi Function Reference

Architecture documentation for the _startup() function in routing.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  2af4237f_f420_ecf2_b2fe_3484aa2c1cb9["_startup()"]
  ecadd3bc_0c58_b4e5_06d8_57da79199adc["APIRouter"]
  2af4237f_f420_ecf2_b2fe_3484aa2c1cb9 -->|defined in| ecadd3bc_0c58_b4e5_06d8_57da79199adc
  02d6cbe5_9949_3a5f_4f41_ee05399bd61e["__aenter__()"]
  02d6cbe5_9949_3a5f_4f41_ee05399bd61e -->|calls| 2af4237f_f420_ecf2_b2fe_3484aa2c1cb9
  style 2af4237f_f420_ecf2_b2fe_3484aa2c1cb9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/routing.py lines 4551–4564

    async def _startup(self) -> None:
        """
        Run any `.on_startup` event handlers.

        This method is kept for backward compatibility after Starlette removed
        support for on_startup/on_shutdown handlers.

        Ref: https://github.com/Kludex/starlette/pull/3117
        """
        for handler in self.on_startup:
            if is_async_callable(handler):
                await handler()
            else:
                handler()

Domain

Subdomains

Defined In

Called By

Frequently Asked Questions

What does _startup() do?
_startup() is a function in the fastapi codebase, defined in fastapi/routing.py.
Where is _startup() defined?
_startup() is defined in fastapi/routing.py at line 4551.
What calls _startup()?
_startup() is called by 1 function(s): __aenter__.

Analyze Your Own Codebase

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

Try Supermodel Free