MCPcopy Create free account
hub / github.com/modelscope/modelscope / _is_free_port

Function _is_free_port

modelscope/utils/torch_utils.py:31–35  ·  view source on GitHub ↗
(port: int)

Source from the content-addressed store, hash-verified

29
30
31def _is_free_port(port: int) -> bool:
32 ips = socket.gethostbyname_ex(socket.gethostname())[-1]
33 ips.append('localhost')
34 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
35 return all(s.connect_ex((ip, port)) != 0 for ip in ips)
36
37
38def compile_model(model, **compile_options):

Callers 2

__init__Method · 0.90
_init_dist_slurmFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…