Skip to content

Commit 7f5957d

Browse files
committed
test: remove obsolete server wait helper
1 parent 35f87db commit 7f5957d

1 file changed

Lines changed: 0 additions & 28 deletions

File tree

tests/test_helpers.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import socket
44
import threading
5-
import time
65
from collections.abc import Generator
76
from contextlib import contextmanager, suppress
87
from typing import Any
@@ -58,30 +57,3 @@ def run_uvicorn_in_thread(app: Any, **config_kwargs: Any) -> Generator[str, None
5857
thread.join(timeout=_SERVER_SHUTDOWN_TIMEOUT_S)
5958
with suppress(OSError):
6059
sock.close()
61-
62-
63-
def wait_for_server(port: int, timeout: float = 20.0) -> None:
64-
"""Wait for server to be ready to accept connections.
65-
66-
Polls the server port until it accepts connections or timeout is reached.
67-
This eliminates race conditions without arbitrary sleeps.
68-
69-
Args:
70-
port: The port number to check
71-
timeout: Maximum time to wait in seconds (default 5.0)
72-
73-
Raises:
74-
TimeoutError: If server doesn't start within the timeout period
75-
"""
76-
start_time = time.time()
77-
while time.time() - start_time < timeout:
78-
try:
79-
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
80-
s.settimeout(0.1)
81-
s.connect(("127.0.0.1", port))
82-
# Server is ready
83-
return
84-
except (ConnectionRefusedError, OSError):
85-
# Server not ready yet, retry quickly
86-
time.sleep(0.01)
87-
raise TimeoutError(f"Server on port {port} did not start within {timeout} seconds") # pragma: no cover

0 commit comments

Comments
 (0)