From 12e685a59207031bae6a1cd6e508e609c904d34b Mon Sep 17 00:00:00 2001 From: zqc <835569504@qq.com> Date: Mon, 9 Mar 2026 16:49:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dweb=20socket=E6=BB=A1?= =?UTF-8?q?=E4=BA=86=E5=AF=BC=E8=87=B4=E5=90=8E=E9=9D=A2=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=89=A7=E8=A1=8Cbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- biz/base_frame_processor.py | 43 ++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/biz/base_frame_processor.py b/biz/base_frame_processor.py index d4922ac..c8c3826 100644 --- a/biz/base_frame_processor.py +++ b/biz/base_frame_processor.py @@ -445,30 +445,33 @@ class BaseFrameProcessorWorker(threading.Thread): "result_type": push_actions, "image_base64": img_b64 } + # 先推送到ws队列 try: self.ws_queue.put(msg, timeout=1.0) - if push_actions and len(push_actions) > 0: - # 构建消息 - post_msg = msg.copy() - post_msg['type'] = self.POST_TYPE - post_msg['ori_alert']: result_alerts - - #备用backup - #self.post_executor.submit(self._post_alert, post_msg) - - # 获取视频相关信息(仅HLS模式有) - segment_path = item.get("segment_path") - segment_duration = item.get("segment_duration") - - # 提交到线程池执行(包含视频剪辑和POST) - self.post_executor.submit( - self._process_alert_with_video, - post_msg, - segment_path, - segment_duration - ) except queue.Full: logger.warning("[WARN] ws_send_queue full, drop frame message") + + # 如果有告警,需要POST(即使ws队列满了也要发送) + if push_actions and len(push_actions) > 0: + # 构建消息 + post_msg = msg.copy() + post_msg['type'] = self.POST_TYPE + post_msg['ori_alert'] = result_alerts + + #备用backup + #self.post_executor.submit(self._post_alert, post_msg) + + # 获取视频相关信息(仅HLS模式有) + segment_path = item.get("segment_path") + segment_duration = item.get("segment_duration") + + # 提交到线程池执行(包含视频剪辑和POST) + self.post_executor.submit( + self._process_alert_with_video, + post_msg, + segment_path, + segment_duration + ) except Exception as e: logger.error(