Handle DuckDB lock errors gracefully in UI
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m44s
CI/CD Pipeline / build-engine (push) Has been skipped
CI/CD Pipeline / build-ui (push) Has been skipped

- Catch IOException when engine holds exclusive lock
- Show informative message instead of crashing
This commit is contained in:
bnair123
2025-12-28 00:00:05 +04:00
parent 8a4750c45e
commit 46d7556efb

View File

@@ -9,6 +9,7 @@ from __future__ import annotations
from datetime import datetime from datetime import datetime
from typing import Any from typing import Any
import duckdb
import streamlit as st import streamlit as st
import structlog import structlog
@@ -34,8 +35,11 @@ def get_storage() -> DataStorage | None:
return None return None
storage = DataStorage(db_path, read_only=True) storage = DataStorage(db_path, read_only=True)
storage.connect() try:
return storage storage.connect()
return storage
except duckdb.IOException:
return None
@st.cache_data(ttl=30) @st.cache_data(ttl=30)
@@ -103,9 +107,16 @@ def render_database_status() -> None:
"""Render database connection status.""" """Render database connection status."""
st.subheader("Database Status") st.subheader("Database Status")
settings = get_settings()
db_path = settings.duckdb_path
if not db_path.exists():
st.warning("Database not initialized yet. Start the trading engine first.")
return
storage = get_storage() storage = get_storage()
if storage is None: if storage is None:
st.warning("Database not initialized yet. Start the trading engine first.") st.info(f"Database exists at {db_path} (engine has exclusive lock)")
return return
try: try: