Skip to content

Commit ec69124

Browse files
authored
[Misc] Improve readability of get_open_port function. (#17024)
Signed-off-by: gitover22 <qidizou88@gmail.com>
1 parent d0da99f commit ec69124

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

vllm/utils.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,12 @@ def get_open_port() -> int:
628628
process. Currently it uses 2 ports.
629629
"""
630630
if "VLLM_DP_MASTER_PORT" in os.environ:
631-
dp_port = envs.VLLM_DP_MASTER_PORT
631+
dp_master_port = envs.VLLM_DP_MASTER_PORT
632+
reserved_port_range = range(dp_master_port, dp_master_port + 10)
632633
while True:
633-
port = _get_open_port()
634-
if dp_port <= port < dp_port + 10:
635-
continue
636-
return port
634+
candidate_port = _get_open_port()
635+
if candidate_port not in reserved_port_range:
636+
return candidate_port
637637
return _get_open_port()
638638

639639

0 commit comments

Comments
 (0)