~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
refactor: use SQLAlchemy exceptions instead of string matching
LearningCircuit6cc80e665357
diff --git a/src/local_deep_research/web/auth/cleanup_middleware.py b/src/local_deep_research/web/auth/cleanup_middleware.pyindex 14f1d3c4e0..929841414f 100644--- a/src/local_deep_research/web/auth/cleanup_middleware.py+++ b/src/local_deep_research/web/auth/cleanup_middleware.py@@ -5,6 +5,7 @@ Runs in request context where we have database access.from flask import g, sessionfrom loguru import logger+from sqlalchemy.exc import OperationalError, TimeoutErrorfrom ...database.models import UserActiveResearchfrom .middleware_optimizer import should_skip_database_middleware@@ -53,20 +54,24 @@ def cleanup_completed_research():f"for user {username}")- except Exception as e:- # Don't let cleanup errors break the request- # Handle connection pool exhaustion gracefully- if "QueuePool limit" in str(e) or "connection timed out" in str(e):+ except (OperationalError, TimeoutError) as e:+ # Handle connection pool exhaustion and timeout errors gracefully+ logger.warning(+ f"Database connection issue during cleanup - skipping: {type(e).__name__}"+ )+ try:+ g.db_session.rollback()+ except Exception:+ # Even rollback might fail if connections are exhaustedlogger.warning(- "Database connection pool exhausted during cleanup - skipping"+ "Could not rollback database session during cleanup error")- else:- logger.exception("Error cleaning up completed research")-+ except Exception:+ # Don't let cleanup errors break the request+ logger.exception("Error cleaning up completed research")try:g.db_session.rollback()except Exception:- # Even rollback might fail if connections are exhaustedlogger.warning("Could not rollback database session during cleanup error")