MCPcopy Create free account
hub / github.com/pywebio/PyWebIO / get_free_port

Function get_free_port

pywebio/utils.py:272–280  ·  view source on GitHub ↗

pick a free port number :return int: port number

()

Source from the content-addressed store, hash-verified

270
271
272def get_free_port():
273 """
274 pick a free port number
275 :return int: port number
276 """
277 with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
278 s.bind(('', 0))
279 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
280 return s.getsockname()[1]
281
282
283def random_str(length=16):

Callers 8

targetFunction · 0.85
threadbasedFunction · 0.85
start_serverFunction · 0.85
start_serverFunction · 0.85
start_serverFunction · 0.85
start_serverFunction · 0.85
_path_deployFunction · 0.85
_setup_serverFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…