Skip to content

~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.

fix(db): correct misleading comments about cleanup rate-limiting (#3174)

LearningCircuitd69d3da7c781
diff --git a/src/local_deep_research/database/encrypted_db.py b/src/local_deep_research/database/encrypted_db.py
index 01ae43ba34..da775d8d88 100644
--- a/src/local_deep_research/database/encrypted_db.py
+++ b/src/local_deep_research/database/encrypted_db.py
@@ -772,11 +772,10 @@ class DatabaseManager:
Why we sweep anyway:
1. Prevents unbounded memory growth in _thread_engines dict
- 2. Cleans up associated credentials from thread_local_session
- 3. Defense-in-depth: if @thread_cleanup fails to fire (e.g.
+ 2. Defense-in-depth: if @thread_cleanup fails to fire (e.g.
interpreter crash, daemon thread killed at shutdown), this
catches the leftovers
- 4. Provides observability via log messages
+ 3. Provides observability via log messages
Known limitation: Python recycles thread IDs. A new thread could
get the same ID as a dead thread. The sweep checks
diff --git a/src/local_deep_research/database/thread_local_session.py b/src/local_deep_research/database/thread_local_session.py
index 32da527419..f01150d127 100644
--- a/src/local_deep_research/database/thread_local_session.py
+++ b/src/local_deep_research/database/thread_local_session.py
@@ -168,7 +168,7 @@ class ThreadLocalSessionManager:
Called from:
- processor_v2.py: every ~60s in the queue loop
- - app_factory.py: in teardown_appcontext (rate-limited)
+ - app_factory.py: in teardown_appcontext (engine sweep rate-limited)
- connection_cleanup.py: in cleanup_idle_connections (every ~300s)
"""
alive_ids = {t.ident for t in threading.enumerate()}
diff --git a/src/local_deep_research/web/auth/connection_cleanup.py b/src/local_deep_research/web/auth/connection_cleanup.py
index 1c34343236..c3db0347db 100644
--- a/src/local_deep_research/web/auth/connection_cleanup.py
+++ b/src/local_deep_research/web/auth/connection_cleanup.py
@@ -73,7 +73,8 @@ def cleanup_idle_connections(session_manager, db_manager):
# Sweep dead-thread engines and sessions — safety net when neither HTTP
# requests nor the queue processor are triggering sweeps.
- # Rate-limited internally to at most once per 60 seconds.
+ # Engine sweep is rate-limited internally (at most once per 60s);
+ # session sweep runs unconditionally but is lightweight.
cleanup_dead_threads()