MCPcopy Create free account
hub / github.com/encode/starlette / lifespan_context

Function lifespan_context

tests/test_testclient.py:111–119  ·  view source on GitHub ↗
(app: Starlette)

Source from the content-addressed store, hash-verified

109
110 @asynccontextmanager
111 async def lifespan_context(app: Starlette) -> AsyncGenerator[None, None]:
112 nonlocal startup_task, startup_loop, shutdown_task, shutdown_loop
113
114 startup_task = current_task()
115 startup_loop = get_identity()
116 async with anyio.create_task_group():
117 yield
118 shutdown_task = current_task()
119 shutdown_loop = get_identity()
120
121 async def loop_id(request: Request) -> JSONResponse:
122 return JSONResponse(get_identity())

Callers

nothing calls this directly

Calls 2

current_taskFunction · 0.85
get_identityFunction · 0.85

Tested by

no test coverage detected