diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-02-14 07:04:55 -0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-02-14 10:04:55 -0500 |
| commit | 76990cbbda5d93fda560c8a5ab019860f7efaab7 (patch) | |
| tree | 7e299a0eb50001d19d11120b9acb286744779afc /django/test | |
| parent | 21f9d437374ee078ee46e23b64efa3d52ca6f49a (diff) | |
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 8c775391b78b2a4a2b57c5e89ed4888f36aada4b.
Diffstat (limited to 'django/test')
| -rw-r--r-- | django/test/testcases.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py index 991165c04d..dea7fedbcc 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -1442,7 +1442,7 @@ class LiveServerTestCase(TransactionTestCase): # the server thread. if conn.vendor == 'sqlite' and conn.is_in_memory_db(): # Explicitly enable thread-shareability for this connection - conn.allow_thread_sharing = True + conn.inc_thread_sharing() connections_override[conn.alias] = conn cls._live_server_modified_settings = modify_settings( @@ -1478,10 +1478,9 @@ class LiveServerTestCase(TransactionTestCase): # Terminate the live server's thread cls.server_thread.terminate() - # Restore sqlite in-memory database connections' non-shareability - for conn in connections.all(): - if conn.vendor == 'sqlite' and conn.is_in_memory_db(): - conn.allow_thread_sharing = False + # Restore sqlite in-memory database connections' non-shareability. + for conn in cls.server_thread.connections_override.values(): + conn.dec_thread_sharing() @classmethod def tearDownClass(cls): |
