Fix close-path SQLite lock by releasing write lock before exchange/sim ops.
Also enable WAL and busy_timeout on get_db so concurrent sim writes wait instead of failing immediately. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1591,8 +1591,14 @@ def _purge_key_monitors_if_full_margin():
|
||||
|
||||
|
||||
def get_db():
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
# timeout/busy_timeout: 并发写(平仓握锁 + sim 再开库)时等待而非立刻 database is locked
|
||||
conn = sqlite3.connect(DB_PATH, timeout=30)
|
||||
conn.row_factory = sqlite3.Row
|
||||
try:
|
||||
conn.execute("PRAGMA busy_timeout=30000")
|
||||
conn.execute("PRAGMA journal_mode=WAL")
|
||||
except Exception:
|
||||
pass
|
||||
return conn
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user