mirror of
https://github.com/django/django.git
synced 2025-08-16 00:30:47 +00:00
Refs #34118 -- Adopted asgiref coroutine detection shims.
Thanks to Mariusz Felisiak for review.
This commit is contained in:
parent
a09d39f286
commit
32d70b2f55
15 changed files with 42 additions and 44 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue