From 547a07fa7ec4364ea9ecd2aabfdd16ee4c63003c Mon Sep 17 00:00:00 2001 From: Michael Galler Date: Thu, 20 Aug 2020 18:41:22 +0200 Subject: Fixed #31905 -- Made MiddlewareMixin call process_request()/process_response() with thread sensitive. Co-authored-by: Carlton Gibson --- django/utils/deprecation.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'django/utils') diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py index 3582fcf3a3..b2c681b33c 100644 --- a/django/utils/deprecation.py +++ b/django/utils/deprecation.py @@ -126,10 +126,16 @@ class MiddlewareMixin: """ response = None if hasattr(self, 'process_request'): - response = await sync_to_async(self.process_request)(request) + response = await sync_to_async( + self.process_request, + thread_sensitive=True, + )(request) response = response or await self.get_response(request) if hasattr(self, 'process_response'): - response = await sync_to_async(self.process_response)(request, response) + response = await sync_to_async( + self.process_response, + thread_sensitive=True, + )(request, response) return response def _get_response_none_deprecation(self, get_response): -- cgit v1.3