From 5f914c4fe48e281451e85f547e076af4291aa438 Mon Sep 17 00:00:00 2001 From: butubb <1422726308@qq.com> Date: Sun, 9 Aug 2026 08:04:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=B2=E5=88=A0=E9=99=A4=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=AE=8B=E7=95=99=E5=A4=B1=E8=B4=A5=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=87=BA=E7=8E=B0=E5=9C=A8=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=B1=87=E6=80=BB=20-=20=5Fmerge=5Fstatus=20=E6=B8=85=E7=90=86?= =?UTF-8?q?=E4=B8=8D=E5=9C=A8=20STF=20=E8=AE=BE=E5=A4=87=E6=B1=A0=E4=B8=94?= =?UTF-8?q?=E6=97=A0=E8=BF=90=E8=A1=8C=20worker=20=E7=9A=84=E9=99=88?= =?UTF-8?q?=E6=97=A7=E7=8A=B6=E6=80=81=20-=20/api/summary=20=E6=8C=89?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E8=AE=BE=E5=A4=87=E6=B1=A0=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=EF=BC=8CSTF=20=E5=BC=82=E5=B8=B8=E6=97=B6=E4=B8=8D=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E4=BB=BB=E4=BD=95=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/task_manager.py | 10 ++++++++++ web_server.py | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/core/task_manager.py b/core/task_manager.py index b79a5b4..f83a5cd 100644 --- a/core/task_manager.py +++ b/core/task_manager.py @@ -723,6 +723,16 @@ class TaskManager: worker_status = {w["serial"]: w for w in get_all_worker_status()} running = self.get_running() + # 清理陈旧状态:serial 已不在 STF 设备池、且没有在跑 worker 的条目, + # 避免设备被删除后其失败记录仍残留在"异常汇总"里 + present = {dev.get("serial", "") for dev in all_devices} + for serial, w in list(worker_status.items()): + if serial in present or serial in running: + continue + if w.get("status") in ("running", "connecting"): + continue + _remove_worker(serial) + result = [] for dev in all_devices: serial = dev.get("serial", "") diff --git a/web_server.py b/web_server.py index af85996..a0ccfb7 100644 --- a/web_server.py +++ b/web_server.py @@ -158,6 +158,15 @@ def api_summary(): """ try: sts = get_all_worker_status() + # 已删除/不在当前 STF 设备池的设备,其陈旧失败记录不应展示。 + # 复用 get_status 缓存(顺带触发上面的状态清理),STF 异常时不隐藏任何记录。 + try: + devices, derr = mgr.get_status() + if not derr: + present = {d.get("serial") for d in devices} + sts = [s for s in sts if s.get("serial") in present] + except Exception: + pass counts = {"total": 0, "running": 0, "done": 0, "error": 0, "failed": 0, "idle": 0} errors = []