Home / Function/ _wrap_gen_lifespan_context() — fastapi Function Reference

_wrap_gen_lifespan_context() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  6c327ac9_4150_128f_0bae_3ab3977f34f5["_wrap_gen_lifespan_context()"]
  de395a51_26f8_3424_1af0_2f5bef39c893["routing.py"]
  6c327ac9_4150_128f_0bae_3ab3977f34f5 -->|defined in| de395a51_26f8_3424_1af0_2f5bef39c893
  fbb5c527_c628_1375_0b4b_0dc27f28dba6["__init__()"]
  fbb5c527_c628_1375_0b4b_0dc27f28dba6 -->|calls| 6c327ac9_4150_128f_0bae_3ab3977f34f5
  style 6c327ac9_4150_128f_0bae_3ab3977f34f5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/routing.py lines 179–193

def _wrap_gen_lifespan_context(
    lifespan_context: Callable[[Any], Generator[Any, Any, Any]],
) -> Callable[[Any], AbstractAsyncContextManager[Any]]:
    """
    Wrap a generator-based lifespan context into an async context manager.

    This is vendored from Starlette to avoid importing private symbols.
    """
    cmgr = contextlib.contextmanager(lifespan_context)

    @functools.wraps(cmgr)
    def wrapper(app: Any) -> _AsyncLiftContextManager[Any]:
        return _AsyncLiftContextManager(cmgr(app))

    return wrapper

Domain

Subdomains

Defined In

Called By

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free