fix: add use_conn() context manager to prevent SQLite connection leak - #32967
fix: add use_conn() context manager to prevent SQLite connection leak#32967Tomatoooogerambo wants to merge 2 commits into
Conversation
kanban_db.connect() returned an open connection with no safety net. 22 callers in plugin_api.py had to manually try/finally/conn.close(), making it easy to leak connections (~1MB each) on any code path that forgets the cleanup. Changes: - Add use_conn(db_path, board) context manager to kanban_db.py that wraps connect() with auto-close on exit - Convert _conn() in plugin_api.py to a @contextlib.contextmanager using use_conn() internally - Migrate all 22 dashboard API handlers from manual conn = _conn(...) / try/finally/conn.close() to with _conn(...) as conn: (automatic close) The existing connect() function is preserved for callers that need to return a connection (dispatcher, event stream).
|
Related to the kanban SQLite connection leak cluster: #28802, #28803 (specify helpers), #29525, #30027, #30031 (boards list), #32415 (superset combining decompose + ROLLBACK). This PR adds |
# Conflicts: # hermes_cli/kanban_db.py
|
@alt-glitch The merge conflict has been resolved. Could you please approve the workflow run? This is my first PR to hermes-agent, so CI is stuck at "awaiting approval". Thanks! |
|
Thanks for the cleanup work. This automated hermes-sweeper review found that the FD-leak guarantee is already on current
The PR branch is also substantially behind current main, and its |
kanban_db.connect() returned an open connection with no safety net. 22 callers in plugin_api.py had to manually try/finally/conn.close(), making it easy to leak connections (~1MB each) on any code path that forgets the cleanup.
Changes:
The existing connect() function is preserved for callers that need to return a connection (dispatcher, event stream).
What does this PR do?
Related Issue
Fixes #
Type of Change
Changes Made
How to Test
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs