fix: 全部写库scanner统一加busy_timeout=30000——整点撞锁SQLite自动等待,根治崩溃

This commit is contained in:
xxm
2026-08-18 10:00:19 +08:00
parent e18cf7e76e
commit 0070141bce
6 changed files with 23 additions and 0 deletions
+3
View File
@@ -52,6 +52,7 @@ def load_mkt_rsi():
"""从 stock_daily 计算大盘 RSI14(与回测零偏差——回测用的就是 stock_daily"""
try:
conn = sqlite3.connect(str(DB_PATH), timeout=5)
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-18 整点撞锁等待
rows = conn.execute(
"SELECT date, close FROM stock_daily WHERE code='sh000001'"
" ORDER BY date DESC LIMIT 40").fetchall()
@@ -163,6 +164,7 @@ def main():
# ── 幂等:当天已有 s2_panic 候选则跳过 ──
conn = sqlite3.connect(str(DB_PATH), timeout=5)
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-18 整点撞锁等待
try:
_today = datetime.now().strftime("%Y-%m-%d")
_n = conn.execute(
@@ -207,6 +209,7 @@ def main():
# ── 写 candidatessector='s2_panic'UPSERT)──
conn = sqlite3.connect(str(DB_PATH), timeout=5)
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-18 整点撞锁等待
inserted = 0
for code, sig in found[:top_n]:
name = code