mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #30171 -- Fixed DatabaseError in servers tests.
Made DatabaseWrapper thread sharing logic reentrant. Used a reference
counting like scheme to allow nested uses.
The error appeared after 8c775391b7.
This commit is contained in:
@@ -18,11 +18,10 @@ class LiveServerThreadTest(TestCase):
|
||||
# Pass a connection to the thread to check they are being closed.
|
||||
connections_override = {DEFAULT_DB_ALIAS: conn}
|
||||
|
||||
saved_sharing = conn.allow_thread_sharing
|
||||
conn.inc_thread_sharing()
|
||||
try:
|
||||
conn.allow_thread_sharing = True
|
||||
self.assertTrue(conn.is_usable())
|
||||
self.run_live_server_thread(connections_override)
|
||||
self.assertFalse(conn.is_usable())
|
||||
finally:
|
||||
conn.allow_thread_sharing = saved_sharing
|
||||
conn.dec_thread_sharing()
|
||||
|
||||
Reference in New Issue
Block a user