From 840fbaf6d573c7870ed5dcbca59478aa156c01d8 Mon Sep 17 00:00:00 2001 From: Aman Pandey Date: Tue, 20 Aug 2024 17:02:10 +0530 Subject: [PATCH 1/3] asycn compatible history panel --- debug_toolbar/panels/history/panel.py | 1 + debug_toolbar/toolbar.py | 6 +++++- docs/architecture.rst | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debug_toolbar/panels/history/panel.py b/debug_toolbar/panels/history/panel.py index 508a60577..56a891848 100644 --- a/debug_toolbar/panels/history/panel.py +++ b/debug_toolbar/panels/history/panel.py @@ -16,6 +16,7 @@ class HistoryPanel(Panel): """A panel to display History""" + is_async = True title = _("History") nav_title = _("History") template = "debug_toolbar/panels/history.html" diff --git a/debug_toolbar/toolbar.py b/debug_toolbar/toolbar.py index 35d789a53..36308bba4 100644 --- a/debug_toolbar/toolbar.py +++ b/debug_toolbar/toolbar.py @@ -12,6 +12,7 @@ from django.apps import apps from django.conf import settings from django.core.exceptions import ImproperlyConfigured +from django.core.handlers.asgi import ASGIRequest from django.dispatch import Signal from django.template import TemplateSyntaxError from django.template.loader import render_to_string @@ -106,7 +107,10 @@ def should_render_panels(self): # incompatible with the toolbar until # https://github.com/jazzband/django-debug-toolbar/issues/1430 # is resolved. - render_panels = self.request.META.get("wsgi.multiprocess", True) + if isinstance(self.request, ASGIRequest): + render_panels = False + else: + render_panels = self.request.META.get("wsgi.multiprocess", True) return render_panels # Handle storing toolbars in memory and fetching them later on diff --git a/docs/architecture.rst b/docs/architecture.rst index 0c267c806..c49bfef0f 100644 --- a/docs/architecture.rst +++ b/docs/architecture.rst @@ -82,7 +82,7 @@ Problematic Parts - Support for async and multi-threading: ``debug_toolbar.middleware.DebugToolbarMiddleware`` is now async compatible and can process async requests. However certain panels such as ``SQLPanel``, ``TimerPanel``, ``StaticFilesPanel``, - ``RequestPanel``, ``HistoryPanel`` and ``ProfilingPanel`` aren't fully + ``RequestPanel`` and ``ProfilingPanel`` aren't fully compatible and currently being worked on. For now, these panels are disabled by default when running in async environment. follow the progress of this issue in `Async compatible toolbar project `_. From ba35135d10bc840f7c07fee8ca35e02165533b21 Mon Sep 17 00:00:00 2001 From: Aman Pandey Date: Tue, 27 Aug 2024 20:14:37 +0530 Subject: [PATCH 2/3] Update debug_toolbar/toolbar.py Co-authored-by: Tim Schilling --- debug_toolbar/toolbar.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debug_toolbar/toolbar.py b/debug_toolbar/toolbar.py index 27390d354..30ad06a24 100644 --- a/debug_toolbar/toolbar.py +++ b/debug_toolbar/toolbar.py @@ -109,6 +109,10 @@ def should_render_panels(self): if isinstance(self.request, ASGIRequest): render_panels = False else: + # The wsgi.multiprocess case of being True isn't supported until the + # toolbar has resolved the following issue: + # This type of set up is most likely + # https://github.com/jazzband/django-debug-toolbar/issues/1430 render_panels = self.request.META.get("wsgi.multiprocess", True) return render_panels From 3d1360919a933970e5471814e908ed207dc61bcd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 14:44:47 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- debug_toolbar/toolbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug_toolbar/toolbar.py b/debug_toolbar/toolbar.py index 30ad06a24..eb8789b7f 100644 --- a/debug_toolbar/toolbar.py +++ b/debug_toolbar/toolbar.py @@ -109,7 +109,7 @@ def should_render_panels(self): if isinstance(self.request, ASGIRequest): render_panels = False else: - # The wsgi.multiprocess case of being True isn't supported until the + # The wsgi.multiprocess case of being True isn't supported until the # toolbar has resolved the following issue: # This type of set up is most likely # https://github.com/jazzband/django-debug-toolbar/issues/1430