mirror of
https://github.com/django/django.git
synced 2025-08-01 09:32:50 +00:00
[2.2.x] 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 after8c775391b7
. Backport of76990cbbda
from master.
This commit is contained in:
parent
07b44a251a
commit
37cc6a9dce
7 changed files with 100 additions and 66 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue