From ae8d76a456b64c1c6c4ebf11b6ec33b7df217b1a Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期一, 18 八月 2025 13:43:46 +0800 Subject: [PATCH] bug修复 --- utils/socket_util.py | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/socket_util.py b/utils/socket_util.py index 57ad952..9b2e446 100644 --- a/utils/socket_util.py +++ b/utils/socket_util.py @@ -82,9 +82,11 @@ # 绔彛鏄惁琚崰鐢� -def is_port_bind(port): +def is_port_bind(port, timeout=1): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.settimeout(timeout) result = sock.connect_ex(('127.0.0.1', port)) + sock.close() if result == 0: return True else: @@ -92,4 +94,4 @@ if __name__ == "__main__": - pass + print(is_port_bind(9004)) -- Gitblit v1.8.0