From 97ec997e855faee25f8f2e35734f87afa5af6f95 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 27 八月 2024 17:15:21 +0800 Subject: [PATCH] 9:25之前的订阅数据处理 --- 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