Functions
run_lifespan
2
AsyncIterator[None]
▼
Run the ASGI lifespan protocol as an async context manager.
Sends lifespan.sta…
async
run_lifespan
2
AsyncIterator[None]
▼
async def run_lifespan(app: ASGIApp, config: ServerConfig) -> AsyncIterator[None]
Run the ASGI lifespan protocol as an async context manager.
Sends lifespan.startup on entry, waits for the app to respond with lifespan.startup.complete, yields control to the caller, then sends lifespan.shutdown on exit.
If the app doesn't support lifespan (raises an exception or returns silently during startup), the lifespan is treated as a no-op.
Parameters
| Name | Type | Description |
|---|---|---|
app |
ASGIApp |
The ASGI application. |
config |
ServerConfig |
Server configuration. |
Returns
AsyncIterator[None]