Refs #34118 -- Adopted asgiref coroutine detection shims.

Thanks to Mariusz Felisiak for review.
This commit is contained in:
Carlton Gibson 2022-12-20 11:10:48 +01:00 committed by GitHub
parent a09d39f286
commit 32d70b2f55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 42 additions and 44 deletions

View file

@ -1,4 +1,4 @@
import asyncio
from asgiref.sync import iscoroutinefunction, markcoroutinefunction
from django.http import Http404, HttpResponse
from django.template import engines
@ -15,9 +15,8 @@ log = []
class BaseMiddleware:
def __init__(self, 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
if iscoroutinefunction(self.get_response):
markcoroutinefunction(self)
def __call__(self, request):
return self.get_response(request)