Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async compatible HistoryPanel #1991

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions debug_toolbar/panels/history/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion debug_toolbar/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
salty-ivy marked this conversation as resolved.
Show resolved Hide resolved
else:
render_panels = self.request.META.get("wsgi.multiprocess", True)
salty-ivy marked this conversation as resolved.
Show resolved Hide resolved
return render_panels

# Handle storing toolbars in memory and fetching them later on
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/orgs/jazzband/projects/9>`_.