Commit 545c3159 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Fixed #17251 -- In the select_for_update tests, close manually database...

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
parent 219b41cc
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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()