fix: 全部写库scanner统一加busy_timeout=30000——整点撞锁SQLite自动等待,根治崩溃
This commit is contained in:
@@ -42,6 +42,7 @@ def load_mkt_rsi():
|
||||
"""大盘 RSI14(stock_daily sh000001)"""
|
||||
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()
|
||||
conn.close()
|
||||
@@ -59,6 +60,7 @@ def mcap_quantile(code):
|
||||
"""市值分位(2026-08-17 改用 stock_fundamentals.mcap_total,原 amount 不可靠)"""
|
||||
try:
|
||||
conn = sqlite3.connect(str(DB_PATH), timeout=5)
|
||||
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-18 整点撞锁等待
|
||||
row = conn.execute(
|
||||
"SELECT mcap_total FROM stock_fundamentals WHERE code=? ORDER BY updated_at DESC LIMIT 1",
|
||||
(code,)).fetchone()
|
||||
@@ -66,6 +68,7 @@ def mcap_quantile(code):
|
||||
if not row or not row[0]:
|
||||
return 0.3
|
||||
conn = sqlite3.connect(str(DB_PATH), timeout=5)
|
||||
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-18 整点撞锁等待
|
||||
rows = conn.execute(
|
||||
"SELECT code, mcap_total FROM stock_fundamentals f WHERE updated_at = "
|
||||
"(SELECT MAX(updated_at) FROM stock_fundamentals f2 WHERE f2.code=f.code)"
|
||||
@@ -152,6 +155,7 @@ def main():
|
||||
hits = hits[: args.top]
|
||||
|
||||
conn = sqlite3.connect(str(DB_PATH), timeout=10)
|
||||
conn.execute("PRAGMA busy_timeout=30000") # 2026-08-18 整点撞锁等待
|
||||
inserted = 0
|
||||
for code, name, sig in hits:
|
||||
reasons = (f"rsi={sig['rsi']} mcap_q={sig['mcap_q']} score={sig['score']}")
|
||||
|
||||
Reference in New Issue
Block a user