feat: standardize timeout values to floats in seconds (#1766)
This commit is contained in:
parent
4807eb5a80
commit
2aa1ad2a69
4 changed files with 38 additions and 49 deletions
|
|
@ -273,7 +273,7 @@ class TestClientSessionGroup:
|
|||
"mcp.client.session_group.mcp.stdio_client",
|
||||
),
|
||||
(
|
||||
SseServerParameters(url="http://test.com/sse", timeout=10),
|
||||
SseServerParameters(url="http://test.com/sse", timeout=10.0),
|
||||
"sse",
|
||||
"mcp.client.session_group.sse_client",
|
||||
), # url, headers, timeout, sse_read_timeout
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
"""Test to reproduce issue #88: Random error thrown on response."""
|
||||
|
||||
from collections.abc import Sequence
|
||||
from datetime import timedelta
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
|
@ -93,11 +92,9 @@ async def test_notification_validation_error(tmp_path: Path):
|
|||
assert not slow_request_lock.is_set()
|
||||
|
||||
# Second call should timeout (slow operation with minimal timeout)
|
||||
# Use 10ms timeout to trigger quickly without waiting
|
||||
# Use very small timeout to trigger quickly without waiting
|
||||
with pytest.raises(McpError) as exc_info:
|
||||
await session.call_tool(
|
||||
"slow", read_timeout_seconds=timedelta(microseconds=1)
|
||||
) # artificial timeout that always fails
|
||||
await session.call_tool("slow", read_timeout_seconds=0.000001) # artificial timeout that always fails
|
||||
assert "Timed out while waiting" in str(exc_info.value)
|
||||
|
||||
# release the slow request not to have hanging process
|
||||
|
|
|
|||
|
|
@ -270,12 +270,10 @@ async def test_response_id_non_numeric_string_no_match():
|
|||
async def make_request(client_session: ClientSession):
|
||||
try:
|
||||
# Use a short timeout since we expect this to fail
|
||||
from datetime import timedelta
|
||||
|
||||
await client_session.send_request(
|
||||
ClientRequest(types.PingRequest()),
|
||||
types.EmptyResult,
|
||||
request_read_timeout_seconds=timedelta(seconds=0.5),
|
||||
request_read_timeout_seconds=0.5,
|
||||
)
|
||||
pytest.fail("Expected timeout") # pragma: no cover
|
||||
except McpError as e:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import multiprocessing
|
|||
import socket
|
||||
import time
|
||||
from collections.abc import Generator
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
|
|
@ -2370,8 +2369,8 @@ async def test_streamable_http_transport_deprecated_params_ignored(basic_server:
|
|||
transport = StreamableHTTPTransport( # pyright: ignore[reportDeprecated]
|
||||
url=f"{basic_server_url}/mcp",
|
||||
headers={"X-Should-Be-Ignored": "ignored"},
|
||||
timeout=999,
|
||||
sse_read_timeout=timedelta(seconds=999),
|
||||
timeout=999.0,
|
||||
sse_read_timeout=999.0,
|
||||
auth=None,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue