-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit resource warning if sqlite3 fails to close the database #105539
Comments
What is the consequences if a database is not closed explicitly and fails to be closed at Python exit? Is there a risk of losing data? |
If |
By "fail to be closed", I was thinking about a database connection involved in a reference cycle which is impossible to break, and so close() is never called and the object is never destroyed. |
If the connection object is never destroyed (dealloc or finalize are never called), there is no way to detect that in the extension module that I know about. The proposed change involves both the finalizer and the dealloc callbacks, so I'm relying on them actually being called at some point. |
…te3 tests (#108017) - Use memory_database() helper - Move test utility functions to util.py - Add convenience memory database mixin - Add check() helper for closed connection tests
Congrats :-) IMO it's a nice enhancement. |
Thanks for bringing the idea up in the first place, Victor! :) |
Apparently, I did not cover all cases in #108017; the following now emit resource warnings:
|
…in tests. Follow up to 1a1bfc2. Co-authored-by: Erlend E. Aasland <[email protected]>
…in tests. Follow up to 1a1bfc2. Co-authored-by: Erlend E. Aasland <[email protected]>
…st_sqlite3 (#108360) Follow up to 1a1bfc2. Explicitly manage connections in: - test_audit.test_sqlite3 - test_sqlite3.test_audit - test_sqlite3.test_backup Co-authored-by: Erlend E. Aasland <[email protected]>
See #103837 (comment) and #103837 (comment):
EAA:
VS:
Linked PRs
The text was updated successfully, but these errors were encountered: