[loop-generated] [refactor] Replace bare sqlite3.connect() with context managers #148

Closed
opened 2026-03-15 14:19:54 +00:00 by hermes · 0 comments
Collaborator

Problem

23 sqlite3.connect() calls across src/ use manual conn.close() instead of context managers. If an exception occurs between connect() and close(), the connection leaks.

Affected files

  • spark/eidos.py, spark/memory.py
  • timmy/tools_intro/init.py, timmy/approvals.py, timmy/mcp_tools.py
  • timmy/briefing.py, timmy/semantic_memory.py, timmy/memory/unified.py
  • timmy/memory/vector_store.py, timmy/thinking.py
  • infrastructure/models/registry.py, infrastructure/events/bus.py
  • dashboard/routes/*, dashboard/store.py

Action

Replace conn=sqlite3.connect(); try/finally/conn.close() with: with sqlite3.connect() as conn: pattern.
Split into 2-3 PRs by subsystem. Low risk, mechanical refactor.

## Problem 23 sqlite3.connect() calls across src/ use manual conn.close() instead of context managers. If an exception occurs between connect() and close(), the connection leaks. ## Affected files - spark/eidos.py, spark/memory.py - timmy/tools_intro/__init__.py, timmy/approvals.py, timmy/mcp_tools.py - timmy/briefing.py, timmy/semantic_memory.py, timmy/memory/unified.py - timmy/memory/vector_store.py, timmy/thinking.py - infrastructure/models/registry.py, infrastructure/events/bus.py - dashboard/routes/*, dashboard/store.py ## Action Replace conn=sqlite3.connect(); try/finally/conn.close() with: with sqlite3.connect() as conn: pattern. Split into 2-3 PRs by subsystem. Low risk, mechanical refactor.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#148