Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eb7c0a7

Browse files
committed
[3.2.x] Fixed #32614 -- Fixed MiddlewareSyncAsyncTests tests with asgiref 3.3.2+.
Backport of 78fea27 from main
1 parent 1ea5e98 commit eb7c0a7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tests/middleware_exceptions/middleware.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import asyncio
2+
13
from django.http import Http404, HttpResponse
24
from django.template import engines
35
from django.template.response import TemplateResponse
@@ -11,6 +13,9 @@
1113
class BaseMiddleware:
1214
def __init__(self, get_response):
1315
self.get_response = get_response
16+
if asyncio.iscoroutinefunction(self.get_response):
17+
# Mark the class as async-capable.
18+
self._is_coroutine = asyncio.coroutines._is_coroutine
1419

1520
def __call__(self, request):
1621
return self.get_response(request)

0 commit comments

Comments
 (0)