Author: aaugustin
Date: 2011-12-11 00:43:01 -0800 (Sun, 11 Dec 2011)
New Revision: 17195

Modified:
   django/trunk/tests/modeltests/select_for_update/tests.py
Log:
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?\195?\164?\195?\164ri?\195?\164inen for the 
report and patch.



Modified: django/trunk/tests/modeltests/select_for_update/tests.py
===================================================================
--- django/trunk/tests/modeltests/select_for_update/tests.py    2011-12-11 
08:19:04 UTC (rev 17194)
+++ django/trunk/tests/modeltests/select_for_update/tests.py    2011-12-11 
08:43:01 UTC (rev 17195)
@@ -155,7 +155,7 @@
         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 @@
             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 @@
                 )
             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()

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to