_merge_lifespan_context() — fastapi Function Reference
Architecture documentation for the _merge_lifespan_context() function in routing.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 691c784a_b40c_6e15_04d5_454eb7f51d69["_merge_lifespan_context()"] de395a51_26f8_3424_1af0_2f5bef39c893["routing.py"] 691c784a_b40c_6e15_04d5_454eb7f51d69 -->|defined in| de395a51_26f8_3424_1af0_2f5bef39c893 c1d02f65_9a84_123a_bdd4_304e5732f35a["include_router()"] c1d02f65_9a84_123a_bdd4_304e5732f35a -->|calls| 691c784a_b40c_6e15_04d5_454eb7f51d69 style 691c784a_b40c_6e15_04d5_454eb7f51d69 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/routing.py lines 196–210
def _merge_lifespan_context(
original_context: Lifespan[Any], nested_context: Lifespan[Any]
) -> Lifespan[Any]:
@asynccontextmanager
async def merged_lifespan(
app: AppType,
) -> AsyncIterator[Optional[Mapping[str, Any]]]:
async with original_context(app) as maybe_original_state:
async with nested_context(app) as maybe_nested_state:
if maybe_nested_state is None and maybe_original_state is None:
yield None # old ASGI compatibility
else:
yield {**(maybe_nested_state or {}), **(maybe_original_state or {})}
return merged_lifespan # type: ignore[return-value]
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _merge_lifespan_context() do?
_merge_lifespan_context() is a function in the fastapi codebase, defined in fastapi/routing.py.
Where is _merge_lifespan_context() defined?
_merge_lifespan_context() is defined in fastapi/routing.py at line 196.
What calls _merge_lifespan_context()?
_merge_lifespan_context() is called by 1 function(s): include_router.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free