Skip to content

Use weakref finalize to close sqlite.conenctions#15152

Open
mroeschke wants to merge 1 commit intoipython:mainfrom
mroeschke:fix/sqlite3/close
Open

Use weakref finalize to close sqlite.conenctions#15152
mroeschke wants to merge 1 commit intoipython:mainfrom
mroeschke:fix/sqlite3/close

Conversation

@mroeschke
Copy link

@mroeschke mroeschke commented Mar 10, 2026

Maybe closes #15128. (We can sometimes see a similar ResourceWarning when running the pandas tests suite)

weakref.finalize is the recommended way to run cleanup routines compared to __del__ https://docs.python.org/3/library/weakref.html#comparing-finalizers-with-del-methods, so defined a self._finalizer to close the sqlite3.Connection. Additionally, adds a "error::ResourceWarning" warning filter to pytest so these warnings are treated as errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] sqlite3 warning

1 participant