+
    Q(iX                    j    R t ^ RIHt ^ RIHtHtHt ^ RIHtH	t	H
t
 ^ RIHtHt ]! R4      tR R ltR# )	zALifespan utilities for combining async context manager lifespans.)annotations)AsyncIteratorCallableMapping)AbstractAsyncContextManagerAsyncExitStackasynccontextmanager)AnyTypeVarAppTc                    V ^8  d   QhRRRR/# )   	lifespanszGCallable[[AppT], AbstractAsyncContextManager[Mapping[str, Any] | None]]returnz=Callable[[AppT], AbstractAsyncContextManager[dict[str, Any]]] )formats   "`/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/utilities/lifespan.py__annotate__r      s     , ,W,B,    c                 ,   a  \         R V 3R ll4       pV# )aw  Combine multiple lifespans into a single lifespan.

Useful when mounting FastMCP into FastAPI and you need to run
both your app's lifespan and the MCP server's lifespan.

Works with both FastAPI-style lifespans (yield None) and FastMCP-style
lifespans (yield dict). Results are merged; later lifespans override
earlier ones on key conflicts.

Lifespans are entered in order and exited in reverse order (LIFO).

Example:
    ```python
    from fastmcp import FastMCP
    from fastmcp.utilities.lifespan import combine_lifespans
    from fastapi import FastAPI

    mcp = FastMCP("Tools")
    mcp_app = mcp.http_app()

    app = FastAPI(lifespan=combine_lifespans(app_lifespan, mcp_app.lifespan))
    app.mount("/mcp", mcp_app)  # MCP endpoint at /mcp
    ```

Args:
    *lifespans: Lifespan context manager factories to combine.

Returns:
    A combined lifespan context manager factory.
c                    V ^8  d   QhRRRR/# )r   appr   r   zAsyncIterator[dict[str, Any]]r   )r   s   "r   r   'combine_lifespans.<locals>.__annotate__/   s      D %B r   c               8  <"   / p\        4       ;_uu_4       GR j  xL
 pS F9  pVP                  V! V 4      4      G R j  xL
 pVf   K(  VP                  V4       K;  	  V5x  R R R 4      GR j  xL
  R #  LZ L8 L
  + GR j  xL 
 '       g   i     R # ; i5i)N)r   enter_async_contextupdate)r   mergedstacklsresultr   s   &    r   combined#combine_lifespans.<locals>.combined.   so     !#!###u$88CAA%MM&)   L $##A $###sb   BA7B A= A9
A=A=%B0A;1B9A=;B=B	B
B	B		B)r   )r   r    s   j r   combine_lifespansr"      s    D   Or   N)__doc__
__future__r   collections.abcr   r   r   
contextlibr   r   r   typingr	   r
   r   r"   r   r   r   <module>r(      s(    G " < < W W v,r   