From 370c905781b7d6018b8c729bf2805bb6d9931a0b Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 5 Jun 2025 11:05:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20cd=20BrokenPipeError=E6=97=B6=E5=B0=9D?= =?UTF-8?q?=E8=AF=95=E5=86=8D=E5=BB=BA=E7=AB=8B=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/em/cd.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/em/cd.py b/apps/em/cd.py index 11683729..02d3cf33 100644 --- a/apps/em/cd.py +++ b/apps/em/cd.py @@ -22,6 +22,13 @@ def get_tyy_data_t(host, port): try: sc = socket.socket() sc.connect((host, int(port))) + except BrokenPipeError: + try: + sc.close() + except Exception: + pass + sc = socket.socket() + sc.connect((host, int(port))) except OSError as e: cache.set(cd_thread_key, {"err_msg": f"采集器连接失败-{str(e)}"}) except ConnectionResetError: @@ -52,7 +59,7 @@ def get_tyy_data(*args): num = 0 while True: num += 1 - if num > 6: + if num > 8: break val = cache.get(cd_thread_key) if isinstance(val, dict):