Fixed #32614 -- Fixed MiddlewareSyncAsyncTests tests with asgiref 3.3.2+.

This commit is contained in:
Mariusz Felisiak 2021-04-06 08:03:43 +02:00 committed by GitHub
parent 0f7afd6599
commit 78fea27f69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -1,3 +1,5 @@
import asyncio
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
from django.template import engines from django.template import engines
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
@ -11,6 +13,9 @@ log = []
class BaseMiddleware: class BaseMiddleware:
def __init__(self, get_response): def __init__(self, get_response):
self.get_response = get_response self.get_response = get_response
if asyncio.iscoroutinefunction(self.get_response):
# Mark the class as async-capable.
self._is_coroutine = asyncio.coroutines._is_coroutine
def __call__(self, request): def __call__(self, request):
return self.get_response(request) return self.get_response(request)