diff options
| author | Iuri de Silvio <iurisilvio@gmail.com> | 2021-10-31 21:54:13 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-11-03 09:39:27 +0100 |
| commit | 3ff7b15bb79f2ee5b7af245c55ae14546243bb77 (patch) | |
| tree | 98996be397996f56aae0e2fe7fc967b6663db172 /tests | |
| parent | 0c05c183e414fcf83763ca83f97de873e613c162 (diff) | |
Fixed #33252 -- Made cache middlewares thread-safe.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cache/tests.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 13ff0a45aa..ddfe9ddfe6 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -2488,6 +2488,21 @@ class CacheMiddlewareTest(SimpleTestCase): self.assertIn('Cache-Control', response) self.assertIn('Expires', response) + def test_per_thread(self): + """The cache instance is different for each thread.""" + thread_caches = [] + middleware = CacheMiddleware(empty_response) + + def runner(): + thread_caches.append(middleware.cache) + + for _ in range(2): + thread = threading.Thread(target=runner) + thread.start() + thread.join() + + self.assertIsNot(thread_caches[0], thread_caches[1]) + @override_settings( CACHE_MIDDLEWARE_KEY_PREFIX='settingsprefix', |
