mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed ResourceWarning from unclosed SQLite connection on Python 3.13+.
- backends.sqlite.tests.ThreadSharing.test_database_sharing_in_threads
- backends.tests.ThreadTests.test_default_connection_thread_local:
on SQLite, close() doesn't explicitly close in-memory connections.
- servers.tests.LiveServerInMemoryDatabaseLockTest
- test_runner.tests.SQLiteInMemoryTestDbs.test_transaction_support
Check out https://github.com/python/cpython/pull/108015.
This commit is contained in:
@@ -115,6 +115,7 @@ class LiveServerInMemoryDatabaseLockTest(LiveServerBase):
|
||||
connection.
|
||||
"""
|
||||
conn = self.server_thread.connections_override[DEFAULT_DB_ALIAS]
|
||||
source_connection = conn.connection
|
||||
# Open a connection to the database.
|
||||
conn.connect()
|
||||
# Create a transaction to lock the database.
|
||||
@@ -128,6 +129,7 @@ class LiveServerInMemoryDatabaseLockTest(LiveServerBase):
|
||||
finally:
|
||||
# Release the transaction.
|
||||
cursor.execute("ROLLBACK")
|
||||
source_connection.close()
|
||||
|
||||
|
||||
class FailingLiveServerThread(LiveServerThread):
|
||||
|
||||
Reference in New Issue
Block a user