From dfb13ac45518a1a6c26e3d9223f44612fa2778ac Mon Sep 17 00:00:00 2001 From: Liangsheng Yin Date: Sun, 3 Mar 2024 17:09:16 +0800 Subject: [PATCH] Fix addr reuse in check_port (#253) --- python/sglang/srt/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/sglang/srt/utils.py b/python/sglang/srt/utils.py index 7bd8aaafe..86680c3bb 100644 --- a/python/sglang/srt/utils.py +++ b/python/sglang/srt/utils.py @@ -103,6 +103,7 @@ def alloc_usable_network_port(num, used_list=()): def check_port(port): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: try: + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(("", port)) return True except socket.error: