mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-27 07:50:43 +02:00
Route client request timeout through float seconds (SDK v2)
This commit is contained in:
parent
f9b5ec3c95
commit
7dc524371e
2 changed files with 5 additions and 9 deletions
|
|
@ -57,10 +57,7 @@ from fastmcp.client.tasks import (
|
|||
from fastmcp.mcp_config import MCPConfig
|
||||
from fastmcp.utilities.exceptions import get_catch_handlers
|
||||
from fastmcp.utilities.logging import get_logger
|
||||
from fastmcp.utilities.timeout import (
|
||||
normalize_timeout_to_seconds,
|
||||
normalize_timeout_to_timedelta,
|
||||
)
|
||||
from fastmcp.utilities.timeout import normalize_timeout_to_seconds
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastmcp.server import FastMCP
|
||||
|
|
@ -305,8 +302,8 @@ class Client(
|
|||
|
||||
self._progress_handler = progress_handler
|
||||
|
||||
# Convert timeout to timedelta if needed
|
||||
timeout = normalize_timeout_to_timedelta(timeout)
|
||||
# Convert request timeout to float seconds (0 means disabled -> None)
|
||||
read_timeout_seconds = normalize_timeout_to_seconds(timeout)
|
||||
|
||||
# handle init handshake timeout (0 means disabled)
|
||||
if init_timeout is None:
|
||||
|
|
@ -320,7 +317,7 @@ class Client(
|
|||
"list_roots_callback": None,
|
||||
"logging_callback": create_log_callback(log_handler),
|
||||
"message_handler": message_handler or TaskNotificationHandler(self),
|
||||
"read_timeout_seconds": timeout,
|
||||
"read_timeout_seconds": read_timeout_seconds,
|
||||
"client_info": client_info,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import abc
|
||||
import contextlib
|
||||
import datetime
|
||||
from collections.abc import AsyncIterator
|
||||
from typing import Literal, TypeVar
|
||||
|
||||
|
|
@ -23,7 +22,7 @@ ClientTransportT = TypeVar("ClientTransportT", bound="ClientTransport")
|
|||
class SessionKwargs(TypedDict, total=False):
|
||||
"""Keyword arguments for the MCP ClientSession constructor."""
|
||||
|
||||
read_timeout_seconds: datetime.timedelta | None
|
||||
read_timeout_seconds: float | None
|
||||
sampling_callback: SamplingFnT | None
|
||||
sampling_capabilities: mcp_types.SamplingCapability | None
|
||||
list_roots_callback: ListRootsFnT | None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue