From 545c3159f57ca110f1b60f1f82b672a3a1b95b2c Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 11 Dec 2011 08:43:01 +0000 Subject: Fixed #17251 -- In the select_for_update tests, close manually database connections made in threads, so they don't stay "idle in transaction" until the GC deletes them. Thanks Anssi Kääriäinen for the report and patch. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.djangoproject.com/svn/django/trunk@17195 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/select_for_update/tests.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/modeltests/select_for_update/tests.py b/tests/modeltests/select_for_update/tests.py index efaffb9b87..65bc13a1f9 100644 --- a/tests/modeltests/select_for_update/tests.py +++ b/tests/modeltests/select_for_update/tests.py @@ -155,7 +155,7 @@ class SelectForUpdateTests(TransactionTestCase): Person instances. After the select_for_update, it attempts to update the name of the only record, save, and commit. - In general, this will be run in a separate thread. + This function expects to run in a separate thread. """ status.append('started') try: @@ -173,6 +173,10 @@ class SelectForUpdateTests(TransactionTestCase): status.append(e) except Exception, e: raise + finally: + # This method is run in a separate thread. It uses its own + # database connection. Close it without waiting for the GC. + connection.close() @requires_threading @skipUnlessDBFeature('has_select_for_update') @@ -244,6 +248,11 @@ class SelectForUpdateTests(TransactionTestCase): ) except DatabaseError, e: status.append(e) + finally: + # This method is run in a separate thread. It uses its own + # database connection. Close it without waiting for the GC. + connection.close() + status = [] thread = threading.Thread(target=raw, kwargs={'status': status}) thread.start() -- cgit v1.3