From 0feb486a5459d7901e03afc3acd0528ea960a621 Mon Sep 17 00:00:00 2001 From: xxm Date: Sat, 22 Aug 2026 01:30:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(promote=5Fcandidates):=20=E8=A1=A5=5Fexec?= =?UTF-8?q?=5Fretry=E5=AE=9A=E4=B9=89(DB=E9=94=81=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E9=87=8D=E8=AF=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/promote_candidates.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deploy/profile-scripts/promote_candidates.py b/deploy/profile-scripts/promote_candidates.py index f1bad2f9..bbe97401 100644 --- a/deploy/profile-scripts/promote_candidates.py +++ b/deploy/profile-scripts/promote_candidates.py @@ -14,6 +14,22 @@ try: except Exception: pass +import time as _time + +def _exec_retry(conn, sql, params=(), retries=5, wait=2): + """DB写操作自动重试(database is locked时指数退避)""" + for attempt in range(retries): + try: + return conn.execute(sql, params) + except sqlite3.OperationalError as e: + if "locked" in str(e).lower() and attempt < retries - 1: + _time.sleep(wait * (attempt + 1)) + print(f" [DB锁重试{attempt+1}/{retries}] {wait*(attempt+1)}s", flush=True) + else: + raise + return None + + DB_PATH = Path("/home/hmo/MoFin/data/mofin.db") # 2026-08-10 修复参数:控制单次运行时长,防 hermes 600s 超时杀进程