fix(state): avoid overlapping context manager change

This commit is contained in:
fangliquan
2026-08-17 09:24:07 +08:00
committed by Teknium
parent b454e4da76
commit 59c7a99084
2 changed files with 0 additions and 17 deletions
-6
View File
@@ -4429,12 +4429,6 @@ class SessionDB(SessionSearchMixin, SessionSchemaMixin, SessionPortabilityMixin)
conn, self._conn = self._conn, None
self._close_connection_quietly(conn)
def __enter__(self) -> "SessionDB":
return self
def __exit__(self, _exc_type, _exc, _tb) -> None:
self.close()
def __del__(self) -> None:
"""Safety net: close the connection if the caller forgot.
-11
View File
@@ -104,17 +104,6 @@ def _no_fts_rebuild_throttle(monkeypatch):
class TestConnectionLifecycle:
def test_context_manager_closes_connection(self, tmp_path):
from hermes_cli.sqlite_safe_read import has_live_connection
db_path = tmp_path / "context-managed.db"
with SessionDB(db_path=db_path) as managed:
managed.create_session("s-context", source="test")
assert has_live_connection(db_path) is True
assert managed._conn is None
assert has_live_connection(db_path) is False
def test_failed_writable_open_does_not_leak_tracked_connection(
self, tmp_path, monkeypatch
):