Handle DuckDB lock errors gracefully in UI
- Catch IOException when engine holds exclusive lock - Show informative message instead of crashing
This commit is contained in:
@@ -9,6 +9,7 @@ from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
import duckdb
|
||||
import streamlit as st
|
||||
import structlog
|
||||
|
||||
@@ -34,8 +35,11 @@ def get_storage() -> DataStorage | None:
|
||||
return None
|
||||
|
||||
storage = DataStorage(db_path, read_only=True)
|
||||
try:
|
||||
storage.connect()
|
||||
return storage
|
||||
except duckdb.IOException:
|
||||
return None
|
||||
|
||||
|
||||
@st.cache_data(ttl=30)
|
||||
@@ -103,9 +107,16 @@ def render_database_status() -> None:
|
||||
"""Render database connection 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()
|
||||
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
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user