A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 13:30 UTC
[Misc] Improve readability of get_open_port function. (#17024)
Signed-off-by: gitover22 <qidizou88@gmail.com>
huafeng committed
Apr 23, 2025 at 14:16 UTC
ec69124eb4729840d0bfbfa4f84608d0f48ff9a5
1 file changed
+5
-5
vllm/utils.py
+5
-5
@@ -628,12 +628,12 @@ def get_open_port() -> int:
628
process. Currently it uses 2 ports.
629
"""
630
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)
633
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
637
return _get_open_port()
638
639