diff options
| author | Adam Johnson <me@adamj.eu> | 2021-12-21 07:41:29 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-21 08:41:29 +0100 |
| commit | 33401cba9317de2487c31ffdd1a5a51ecfbc0248 (patch) | |
| tree | dea5b471bb8fc13ea475ae03523b7cb900db9ad6 /django/utils/deprecation.py | |
| parent | cc752c1c3a9534dee2377a4ac0d241b8858fe8da (diff) | |
Optimized MiddlewareMixin coroutine check.
Diffstat (limited to 'django/utils/deprecation.py')
| -rw-r--r-- | django/utils/deprecation.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py index f64bc3c6fb..48209bcdf1 100644 --- a/django/utils/deprecation.py +++ b/django/utils/deprecation.py @@ -112,10 +112,12 @@ class MiddlewareMixin: # Mark the class as async-capable, but do the actual switch # inside __call__ to avoid swapping out dunder methods self._is_coroutine = asyncio.coroutines._is_coroutine + else: + self._is_coroutine = None def __call__(self, request): # Exit out to async mode, if needed - if asyncio.iscoroutinefunction(self.get_response): + if self._is_coroutine: return self.__acall__(request) response = None if hasattr(self, 'process_request'): |
