[Misc] Improve readability of get_open_port function. (#17024)

Signed-off-by: gitover22 <qidizou88@gmail.com>
This commit is contained in:
huafeng 2025-04-23 14:16:53 +08:00 committed by GitHub
parent d0da99fb70
commit ec69124eb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -628,12 +628,12 @@ def get_open_port() -> int:
process. Currently it uses 2 ports. process. Currently it uses 2 ports.
""" """
if "VLLM_DP_MASTER_PORT" in os.environ: if "VLLM_DP_MASTER_PORT" in os.environ:
dp_port = envs.VLLM_DP_MASTER_PORT dp_master_port = envs.VLLM_DP_MASTER_PORT
reserved_port_range = range(dp_master_port, dp_master_port + 10)
while True: while True:
port = _get_open_port() candidate_port = _get_open_port()
if dp_port <= port < dp_port + 10: if candidate_port not in reserved_port_range:
continue return candidate_port
return port
return _get_open_port() return _get_open_port()