mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-23 05:54:19 +02:00
Avoid hanging on initialize
This commit is contained in:
parent
51db31576e
commit
be95110596
1 changed files with 6 additions and 0 deletions
|
|
@ -1,8 +1,10 @@
|
|||
import asyncio
|
||||
import datetime
|
||||
from contextlib import AsyncExitStack, asynccontextmanager
|
||||
from pathlib import Path
|
||||
from typing import Any, cast
|
||||
|
||||
import anyio
|
||||
import mcp.types
|
||||
from exceptiongroup import catch
|
||||
from mcp import ClientSession
|
||||
|
|
@ -161,7 +163,11 @@ class Client:
|
|||
self._initialize_result = await self._session.initialize()
|
||||
|
||||
try:
|
||||
with anyio.fail_after(1):
|
||||
self._initialize_result = await self._session.initialize()
|
||||
yield
|
||||
except asyncio.TimeoutError:
|
||||
raise RuntimeError("Failed to initialize server session")
|
||||
finally:
|
||||
self._exit_stack = None
|
||||
self._session = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue