Repository navigation
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #68 +/- ##
=======================================
Coverage ? 69.63%
=======================================
Files ? 20
Lines ? 3122
Branches ? 0
=======================================
Hits ? 2174
Misses ? 948
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sqlite3's connection context manager commits or rolls back but never closes the connection, so every `with _connect(path) as connection:` in the analytics helpers relied on CPython refcounting to close it. _connect is now a @contextmanager that configures the connection, commits on success, rolls back on error, and always closes it. The six call sites are unchanged. Tests check that every helper closes the connections it opens, and that _connect commits on success and rolls back and closes on error. Split out of m-beau#52. Assisted-by: ClaudeCode:claude-opus-5-5
tabedzki
force-pushed
the
tabedzki/refactor/analytics-close-connections
branch
from
October 16, 2026 20:12
c47e1db to
a551aea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Split out of #52 (the analytics half).
What
_connectinpixelmap/analytics.pyis now a@contextlib.contextmanager. It opens and configures the connection (row factory, WAL, foreign keys), commits on success, rolls back on error, and always closes the connection. The six call sites (initialize_database,record_visit,record_session_end,get_total_visits,get_unique_visitors,get_visitor_summary) still usewith _connect(path) as connection:unchanged.Why
sqlite3's connection context manager commits or rolls back, but it does not close the connection. Until now the code depended on CPython refcounting to close it. In practice nothing leaks, but the close is now explicit and handled in one place, so it no longer depends on GC behaviour.
Tests
sqlite3.connect)._connectcommits on success, and rolls back and closes when the body raises.The
_connecttests fail onmain.uv run pytest -q: 573 passed, 1 xfailed.Assisted-by: ClaudeCode:claude-opus-5-5