fix: Replace arbitrary sleeps with active server readiness checks in tests (#1527)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f97f7c4a7d
commit
3e86edfb2f
1 changed files with 45 additions and 98 deletions
|
|
@ -3,7 +3,6 @@
|
|||
import logging
|
||||
import multiprocessing
|
||||
import socket
|
||||
import time
|
||||
from collections.abc import AsyncGenerator
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
|
|
@ -18,6 +17,7 @@ from mcp.server import Server
|
|||
from mcp.server.streamable_http_manager import StreamableHTTPSessionManager
|
||||
from mcp.server.transport_security import TransportSecuritySettings
|
||||
from mcp.types import Tool
|
||||
from tests.test_helpers import wait_for_server
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
SERVER_NAME = "test_streamable_http_security_server"
|
||||
|
|
@ -77,8 +77,8 @@ def start_server_process(port: int, security_settings: TransportSecuritySettings
|
|||
"""Start server in a separate process."""
|
||||
process = multiprocessing.Process(target=run_server_with_settings, args=(port, security_settings))
|
||||
process.start()
|
||||
# Give server time to start
|
||||
time.sleep(1)
|
||||
# Wait for server to be ready to accept connections
|
||||
wait_for_server(port)
|
||||
return process
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue