I have a Django middleware that I want to make async capable. Besides declaring sync_capable
, async_capable
and __call__
, async def __acall__
, should I take other precautions, like exiting out from async mode as showed in MiddlewareMixin?
Edit. Seems this is the minimal check it needs:
def __call__(self, request):
if asyncio.iscoroutinefunction(self.get_response):
return self.__acall__(request)
I’m not subclassing MiddlewareMixin
. Thanks!