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 超时杀进程