From dd4636adb21cba5eec0b217b14b1d2bd09d0a09c Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期五, 12 七月 2024 13:51:21 +0800
Subject: [PATCH] 检测/修复数据服务

---
 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