Fix unclosed sqlite3 connections in updates.py#270
Merged
Conversation
Python's `with sqlite3.connect() as conn` manages transactions but does NOT close the connection on exit — it stays open until GC'd, triggering ResourceWarning. Fix set_initial_updates to reuse the existing Peewee connection via execute_sql(), and fix schema_change_20_compound_keys to use contextlib.closing() so the connection is explicitly closed.
cmutel
added a commit
that referenced
this pull request
May 14, 2026
cmutel
added a commit
that referenced
this pull request
May 14, 2026
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.
Closes #269
Summary
set_initial_updates()ranPRAGMA table_info(activitydataset)via a freshsqlite3.connect(), even though the Peewee-managed connection was already open — replaced withsqlite3_lci_db.execute_sql(SQL), eliminating the extra connection entirelyschema_change_20_compound_keys()opened a connection withwith sqlite3.connect(...) as conn— replaced withcontextlib.closing(sqlite3.connect(...))so the connection is explicitly closed on exitRoot cause
Python's
with sqlite3.connect(...) as connmanages the transaction context but does not close the connection when the block exits. Connections stayed open until GC'd, triggeringResourceWarning: unclosed databaseacross many tests.Test plan
ResourceWarning: unclosed databasein test output