From f8b8db2d79d76a3fd92497a2d12f106c509ff98c Mon Sep 17 00:00:00 2001 From: yeuimu <2197651308@qq.com> Date: Fri, 31 Jul 2026 05:44:52 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20label-ocr=20=E9=98=B2=E9=87=8D=E5=85=A5?= =?UTF-8?q?=E6=94=B9=E7=94=A8=20count>1=20=E9=81=BF=E5=85=8D=E8=87=AA?= =?UTF-8?q?=E6=A3=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flows/label_ocr.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/flows/label_ocr.py b/flows/label_ocr.py index 5e1ceff..aad64af 100644 --- a/flows/label_ocr.py +++ b/flows/label_ocr.py @@ -10,7 +10,7 @@ import os import httpx from prefect import flow, task -from prefect.runtime import deployment, flow_run +from prefect.runtime import deployment from api.ocr import OcrClient, country_to_ocr_code from flows.shared import SyncDB, build_stats_rows, emit_sync_summary @@ -33,9 +33,8 @@ def _result_to_fields(r) -> dict[str, str | None]: def _has_running_peer() -> bool: - """检查是否有同类 flow run 正在运行(排除自身)。""" + """检查是否有同类 flow run 正在运行(查到 >1 个说明有其他实例)。""" api_url = os.environ.get("PREFECT_API_URL", "http://localhost:4200/api") - cur_id = str(flow_run.id) if flow_run.id else "" dep_id = str(deployment.id) if deployment.id else "" if not dep_id: return False @@ -50,7 +49,7 @@ def _has_running_peer() -> bool: timeout=10, ) resp.raise_for_status() - return any(r["id"] != cur_id for r in resp.json()) + return len(resp.json()) > 1 except Exception: return False