Skip to content

The agent that grows with you

fix: __del__ delegates to close() for full cleanup

kshitij7a390f7c43a5
diff --git a/hermes_state.py b/hermes_state.py
index 675a0b24a31..3711e91f496 100644
--- a/hermes_state.py
+++ b/hermes_state.py
@@ -4036,16 +4036,16 @@ class SessionDB(SessionSearchMixin, SessionSchemaMixin, SessionPortabilityMixin)
reference is the only remaining root and the interpreter is
shutting down. During normal interpreter teardown the order of
module cleanup is undefined, so we guard every attribute access.
+
+ Delegates to ``close()`` so the read pool, token writer, and atexit
+ hook are all cleaned up — not just the writer connection.
"""
+ if self.__dict__.get("_conn") is None:
+ return
try:
- conn = self.__dict__.get("_conn")
+ self.close()
except Exception:
- return
- if conn is not None:
- try:
- conn.close()
- except Exception:
- pass
+ pass
# ── Chunked FTS rebuild engine (v23 opt-in optimize) ──
#