fix: 盘中脚本统一使用get_conn()替代raw sqlite3.connect防DB死锁

- mofin_health.py, cron_health_monitor.py, intraday_health_check.py,
  self_todo_executor.py: 替换raw sqlite3.connect() → get_conn()
  统一使用WAL模式+busy_timeout=30s连接
- mofin_db.py: get_conn()每次新建连接时WAL checkpoint
  防止被kill进程残留WAL导致后续全部卡死
- 并发测试验证: 3x price_monitor + 3x mofin_health同时运行
  6/6通过,WAL仅32bytes

关联问题: 2026-07-14 SQLite写锁死锁根因诊断
This commit is contained in:
知微
2026-07-14 10:56:38 +08:00
parent 3ee3d9ba6c
commit 59e94d135c
6 changed files with 37 additions and 12 deletions
+3 -3
View File
@@ -5,9 +5,10 @@
成功→completed。失败→调gateway API,带完整上下文让知微处理。
"""
import json, sqlite3, subprocess, time, urllib.request
import json, subprocess, time, urllib.request
from pathlib import Path
from datetime import datetime
from mofin_db import get_conn
BASE = Path("/home/hmo/MoFin")
DB_PATH = BASE / "data" / "mofin.db"
@@ -28,8 +29,7 @@ def send_xmpp(msg):
def main():
start = time.time()
conn = sqlite3.connect(str(DB_PATH))
conn.row_factory = sqlite3.Row
conn = get_conn()
rows = conn.execute(
"SELECT id, title, description, fix_action FROM todos WHERE status='pending' "