MCPcopy
hub / github.com/opentrace/opentrace / _find_open_port

Function _find_open_port

agent/src/opentrace_agent/cli/auth.py:283–294  ·  view source on GitHub ↗

Find an available port in the callback range.

()

Source from the content-addressed store, hash-verified

281
282
283def _find_open_port() -> int:
284 """Find an available port in the callback range."""
285 import socket
286
287 for port in CALLBACK_PORT_RANGE:
288 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
289 try:
290 s.bind((CALLBACK_HOST, port))
291 return port
292 except OSError:
293 continue
294 raise RuntimeError(f"No available port in range {CALLBACK_PORT_RANGE.start}-{CALLBACK_PORT_RANGE.stop - 1}")
295
296
297# ---------------------------------------------------------------------------

Callers 1

loginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected