From 545c3159f57ca110f1b60f1f82b672a3a1b95b2c Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 11 Dec 2011 08:43:01 +0000 Subject: [PATCH] =?UTF-8?q?Fixed=20#17251=20--=20In=20the=20select=5Ffor?= =?UTF-8?q?=5Fupdate=20tests,=20close=20manually=20database=20connections?= =?UTF-8?q?=20made=20in=20threads,=20so=20they=20don't=20stay=20"idle=20in?= =?UTF-8?q?=20transaction"=20until=20the=20GC=20deletes=20them.=20Thanks?= =?UTF-8?q?=20Anssi=20K=C3=A4=C3=A4ri=C3=A4inen=20for=20the=20report=20and?= =?UTF-8?q?=20patch.?= 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(-) 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()