MCPcopy Create free account
hub / github.com/FastLED/FastLED / _find_free_port

Function _find_free_port

ci/wasm_test.py:61–70  ·  view source on GitHub ↗

Find a free TCP port starting from `start`.

(start: int = 9123)

Source from the content-addressed store, hash-verified

59
60
61def _find_free_port(start: int = 9123) -> int:
62 """Find a free TCP port starting from `start`."""
63 for port in range(start, start + 100):
64 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
65 try:
66 s.bind(("", port))
67 return port
68 except OSError:
69 continue
70 raise OSError(f"No free port found in range {start}–{start + 99}")
71
72
73class _ReuseAddrTCPServer(socketserver.TCPServer):

Callers 1

mainFunction · 0.70

Calls 2

socketMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected