File tree Expand file tree Collapse file tree 2 files changed +156
-93
lines changed Expand file tree Collapse file tree 2 files changed +156
-93
lines changed Original file line number Diff line number Diff line change 1313from debug_toolbar .toolbar import DebugToolbar
1414from debug_toolbar .utils import clear_stack_trace_caches
1515
16+ try :
17+ from django .core .handlers .asgi import ASGIRequest
18+ except ImportError :
19+ ASGIRequest = None
20+
1621_HTML_TYPES = ("text/html" , "application/xhtml+xml" )
1722
1823
@@ -64,6 +69,10 @@ def __call__(self, request):
6469 if not show_toolbar (request ) or DebugToolbar .is_toolbar_request (request ):
6570 return self .get_response (request )
6671
72+ if self ._check_async_request (request ):
73+ self ._show_async_request_is_not_supported ()
74+ return self .get_response (request )
75+
6776 toolbar = DebugToolbar (request , self .get_response )
6877
6978 # Activate instrumentation ie. monkey-patch.
@@ -124,3 +133,12 @@ def get_headers(request, panels):
124133 else :
125134 headers [header ] = value
126135 return headers
136+
137+ def _check_async_request (self , request ) -> bool :
138+ return type (request ) == ASGIRequest
139+
140+ @staticmethod
141+ def _show_async_request_is_not_supported ():
142+ print ('-' * 10 )
143+ print ('Be caution, django-debug-toolbar does not support async requests!' )
144+ print ('-' * 10 )
You can’t perform that action at this time.
0 commit comments