MCPcopy Create free account
hub / github.com/Azure-Samples/rag-postgres-openai-python / free_port

Function free_port

tests/e2e.py:32–37  ·  view source on GitHub ↗

Returns a free port for the test server to bind.

()

Source from the content-addressed store, hash-verified

30
31@pytest.fixture(scope="session")
32def free_port() -> int:
33 """Returns a free port for the test server to bind."""
34 with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
35 s.bind(("", 0))
36 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
37 return s.getsockname()[1]
38
39
40def run_server(port: int):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected