Skip to content

Commit ddcf62e

Browse files
committed
exit stack
1 parent ce14d07 commit ddcf62e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,10 @@ from mcp.math import math
443443
# Create a combined lifespan to manage both session managers
444444
@contextlib.asynccontextmanager
445445
async def lifespan(app: FastAPI):
446-
async with echo.mcp.session_manager.run():
447-
async with math.mcp.session_manager.run():
448-
yield
446+
async with contextlib.AsyncExitStack() as stack:
447+
await stack.enter_async_context(echo.mcp.session_manager.run())
448+
await stack.enter_async_context(math.mcp.session_manager.run())
449+
yield
449450

450451

451452
app = FastAPI(lifespan=lifespan)

0 commit comments

Comments
 (0)