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

Make Panels non async by default #1990

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion debug_toolbar/panels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Panel:
Base class for panels.
"""

is_async = True
is_async = False

def __init__(self, toolbar, get_response):
self.toolbar = toolbar
Expand Down
2 changes: 2 additions & 0 deletions debug_toolbar/panels/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class AlertsPanel(Panel):

title = _("Alerts")

is_async = True

template = "debug_toolbar/panels/alerts.html"

def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions debug_toolbar/panels/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class CachePanel(Panel):

template = "debug_toolbar/panels/cache.html"

is_async = True

_context_locals = Local()

def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions debug_toolbar/panels/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class HeadersPanel(Panel):

title = _("Headers")

is_async = True

template = "debug_toolbar/panels/headers.html"

def process_request(self, request):
Expand Down
3 changes: 2 additions & 1 deletion debug_toolbar/panels/redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ class RedirectsPanel(Panel):
Panel that intercepts redirects and displays a page with debug info.
"""

is_async = True
has_content = False

is_async = True

nav_title = _("Intercept redirects")

def _process_response(self, response):
Expand Down
2 changes: 0 additions & 2 deletions debug_toolbar/panels/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class RequestPanel(Panel):

title = _("Request")

is_async = False

@property
def nav_subtitle(self):
"""
Expand Down
2 changes: 2 additions & 0 deletions debug_toolbar/panels/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class SettingsPanel(Panel):

template = "debug_toolbar/panels/settings.html"

is_async = True

nav_title = _("Settings")

def title(self):
Expand Down
2 changes: 2 additions & 0 deletions debug_toolbar/panels/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
class SignalsPanel(Panel):
template = "debug_toolbar/panels/signals.html"

is_async = True

SIGNALS = {
"request_started": request_started,
"request_finished": request_finished,
Expand Down
1 change: 0 additions & 1 deletion debug_toolbar/panels/staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class StaticFilesPanel(panels.Panel):
A panel to display the found staticfiles.
"""

is_async = False
name = "Static files"
template = "debug_toolbar/panels/staticfiles.html"

Expand Down
2 changes: 2 additions & 0 deletions debug_toolbar/panels/templates/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class TemplatesPanel(Panel):
A panel that lists all templates used during processing of a response.
"""

is_async = True

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.templates = []
Expand Down
2 changes: 0 additions & 2 deletions debug_toolbar/panels/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class TimerPanel(Panel):
Panel that displays the time a response took in milliseconds.
"""

is_async = False

def nav_subtitle(self):
stats = self.get_stats()
if hasattr(self, "_start_rusage"):
Expand Down
2 changes: 2 additions & 0 deletions debug_toolbar/panels/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class VersionsPanel(Panel):
Shows versions of Python, Django, and installed apps if possible.
"""

is_async = True

@property
def nav_subtitle(self):
return "Django %s" % django.get_version()
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`` and ``ProfilingPanel`` aren't fully
``RequestPanel``, ``HistoryPanel`` 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>`_.