From af8e45ded37b3834c981473b309239e0102473d0 Mon Sep 17 00:00:00 2001 From: Jiakai Tang <58941474+TangJiakai@users.noreply.github.com> Date: Wed, 7 Aug 2024 21:01:12 +0800 Subject: [PATCH] [Hot fix]Fix bugs for port check (#392) --- src/agentscope/utils/tools.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/agentscope/utils/tools.py b/src/agentscope/utils/tools.py index f79a8b754..4e2382fc0 100644 --- a/src/agentscope/utils/tools.py +++ b/src/agentscope/utils/tools.py @@ -85,8 +85,7 @@ def check_port(port: Optional[int] = None) -> int: return new_port with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: try: - code = s.connect_ex(("localhost", port)) - if code != 0: + if s.connect_ex(("localhost", port)) == 0: raise RuntimeError("Port is occupied.") except Exception: new_port = find_available_port()