(
original_context: Lifespan[Any], nested_context: Lifespan[Any]
)
| 223 | |
| 224 | |
| 225 | def _merge_lifespan_context( |
| 226 | original_context: Lifespan[Any], nested_context: Lifespan[Any] |
| 227 | ) -> Lifespan[Any]: |
| 228 | @asynccontextmanager |
| 229 | async def merged_lifespan( |
| 230 | app: AppType, |
| 231 | ) -> AsyncIterator[Mapping[str, Any] | None]: |
| 232 | async with original_context(app) as maybe_original_state: |
| 233 | async with nested_context(app) as maybe_nested_state: |
| 234 | if maybe_nested_state is None and maybe_original_state is None: |
| 235 | yield None # old ASGI compatibility |
| 236 | else: |
| 237 | yield {**(maybe_nested_state or {}), **(maybe_original_state or {})} |
| 238 | |
| 239 | return merged_lifespan # type: ignore[return-value] # ty: ignore[invalid-return-type] |
| 240 | |
| 241 | |
| 242 | class _DefaultLifespan: |
no outgoing calls
no test coverage detected
searching dependent graphs…