summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2011-12-11 08:43:01 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2011-12-11 08:43:01 +0000
commit545c3159f57ca110f1b60f1f82b672a3a1b95b2c (patch)
treed72fcb27b9a21a31389bc59ac05e9ffee0b14ff1 /tests
parent219b41cc155a216fc912cd37f215fb44acee317b (diff)
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.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17195 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/select_for_update/tests.py11
1 files changed, 10 insertions, 1 deletions
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()