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
This commit is contained in:
parent
219b41cc15
commit
545c3159f5
|
@ -155,7 +155,7 @@ class SelectForUpdateTests(TransactionTestCase):
|
||||||
Person instances. After the select_for_update, it attempts
|
Person instances. After the select_for_update, it attempts
|
||||||
to update the name of the only record, save, and commit.
|
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')
|
status.append('started')
|
||||||
try:
|
try:
|
||||||
|
@ -173,6 +173,10 @@ class SelectForUpdateTests(TransactionTestCase):
|
||||||
status.append(e)
|
status.append(e)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
raise
|
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
|
@requires_threading
|
||||||
@skipUnlessDBFeature('has_select_for_update')
|
@skipUnlessDBFeature('has_select_for_update')
|
||||||
|
@ -244,6 +248,11 @@ class SelectForUpdateTests(TransactionTestCase):
|
||||||
)
|
)
|
||||||
except DatabaseError, e:
|
except DatabaseError, e:
|
||||||
status.append(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 = []
|
status = []
|
||||||
thread = threading.Thread(target=raw, kwargs={'status': status})
|
thread = threading.Thread(target=raw, kwargs={'status': status})
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
Loading…
Reference in New Issue