-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
After upgrading to Django 4.2 LTS, I receive AttributeError on each page load. Using DDT 4.0.0 #1769
Comments
Thank you for the report. Can you tell us what function is trying to be
patched? And what are you using for your cache settings in your project?
…On Sat, May 6, 2023, 7:36 AM Thomas Kunambi ***@***.***> wrote:
E0506 14:25:32.246 django.request:241 Internal Server Error: /dashboard/
Traceback (most recent call last):
File "C:\Users\Owner\.virtualenvs\premind-6P0nJig8\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "C:\Users\Owner\.virtualenvs\premind-6P0nJig8\lib\site-packages\sentry_sdk\integrations\django\middleware.py", line 176, in __call__
return f(*args, **kwargs)
File "C:\Users\Owner\.virtualenvs\premind-6P0nJig8\lib\site-packages\debug_toolbar\middleware.py", line 64, in __call__
panel.disable_instrumentation()
File "C:\Users\Owner\.virtualenvs\premind-6P0nJig8\lib\site-packages\debug_toolbar\panels\cache.py", line 217, in disable_instrumentation
self._unmonkey_patch_cache(cache)
File "C:\Users\Owner\.virtualenvs\premind-6P0nJig8\lib\site-packages\debug_toolbar\panels\cache.py", line 171, in _unmonkey_patch_cache
if original_method.__func__ == getattr(cache.__class__, name):
AttributeError: 'function' object has no attribute '__func__'
Commenting debug_toolbar.panels.cache.CachePanel allows DDT to continue
to work.
# settings.pyMIDDLEWARE = [
"django.middleware.gzip.GZipMiddleware",
]
if DEBUG_TOOLBAR:
INSTALLED_APPS += ["debug_toolbar"]
MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"]
DEBUG_TOOLBAR_PANELS = [
"debug_toolbar.panels.history.HistoryPanel",
"debug_toolbar.panels.versions.VersionsPanel",
"debug_toolbar.panels.timer.TimerPanel",
"debug_toolbar.panels.settings.SettingsPanel",
"debug_toolbar.panels.headers.HeadersPanel",
"debug_toolbar.panels.request.RequestPanel",
"debug_toolbar.panels.sql.SQLPanel",
# 'debug_toolbar.panels.staticfiles.StaticFilesPanel', # breaks if minio is enabled
"debug_toolbar.panels.templates.TemplatesPanel",
# "debug_toolbar.panels.cache.CachePanel", # commenting this line allows DDT to continue to work
"debug_toolbar.panels.signals.SignalsPanel",
"debug_toolbar.panels.logging.LoggingPanel",
"debug_toolbar.panels.redirects.RedirectsPanel",
"debug_toolbar.panels.profiling.ProfilingPanel",
]
Please let me know if you need any more information in order to solve this
issue
—
Reply to this email directly, view it on GitHub
<#1769>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJYZP4UMTGEHJQUW7PBYA3XEZAU5ANCNFSM6AAAAAAXYC2YPM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I haven't done any additional patching, just trying to use DDT as usual. My cache settings: if env("CACHE_URL", default=None) is not None:
CACHES = {
"default": env.cache(),
}
if env("SESSION_CACHE_URL", default=None) is not None:
CACHES["session"] = env.cache("SESSION_CACHE_URL")
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "session" My environment file: CACHE_URL=rediscache://localhost:6379/2
SESSION_CACHE_URL=rediscache://localhost:6379/3 |
I have the same problem. It is weird that I somehow can't reproduce it locally.
and sentry says this about locals on the last line:
and cache settings as follows:
|
Are you sure your local instance matches the other environment? Are you
using redis locally?
…On Sat, May 6, 2023, 9:48 AM Dmitry Ulupov ***@***.***> wrote:
I have the same problem. It is weird that I somehow can't reproduce it
locally.
Here is the stack trace:
AttributeError: 'function' object has no attribute '__func__'
File "django/core/handlers/exception.py", line 56, in inner
response = get_response(request)
File "debug_toolbar/middleware.py", line 64, in __call__
panel.disable_instrumentation()
File "debug_toolbar/panels/cache.py", line 217, in disable_instrumentation
self._unmonkey_patch_cache(cache)
File "debug_toolbar/panels/cache.py", line 171, in _unmonkey_patch_cache
if original_method.__func__ == getattr(cache.__class__, name):
and sentry says this about locals on the last line:
cache: <django.core.cache.backends.redis.RedisCache object at
0x7f6395470e10>
name: 'get'
original_method: <function RedisCache.get at 0x7f63954cb2e0>
—
Reply to this email directly, view it on GitHub
<#1769 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJYZP2WORDT23CDNNUTCZDXEZQDDANCNFSM6AAAAAAXYC2YPM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Can you give us more information about how this is running? Is it local via runserver? Is it using gunicorn, etc? |
I'm running redis through a docker container services:
redis:
image: redis:6
ports:
- "6379:6379" The Django app is run through |
The cache call recording has changed a lot in django-debug-toolbar 3.5; could you check if this version also fails? That may be useful. (I cannot reproduce the failure either.) |
Addendum: I cannot reproduce it locally. I haven't tried running the toolbar in a production environment (my opinion and stance is that it is a bad idea) |
It is a weird thing. After many attempts - only hints on how to reproduce it. As a workaround I've disabled cache panel. Now it works okay.
Stack trace with LocMem:
Sorry about messy pip freeze, but maybe it will be helpful. pip freeze
Cache settings:
|
I'm also seeing this after upgrading from django 4.1 to 4.2:
I see sentry in the stacktrace there. AFAIK, sentry does some money-patching too, so there might be a conflict there. My init_sentry(
attach_stacktrace=True,
before_send=before_send,
integrations=[
AwsLambdaIntegration(timeout_warning=True),
CeleryIntegration(),
DjangoIntegration(),
LoggingIntegration(event_level=logging.WARNING),
],
release=version,
in_app_exclude=["logging"],
ignore_errors=["idf.core.views.TestException"],
traces_sample_rate=0,
environment=TENANT_SLUG,
) If I comment out this block, my site works again. It seems that the conflict arises when debug toolbar AND sentry are both present. |
Ah yes, of course. A class instance with a (I wonder if we really should do that much work in |
Since I was the author of those changes I'll try to take a look. |
Hi all. Can anyone test the current |
Hi @matthiask Yes, I'll happily test it. Can you please share exactly what I should type in order to install the package accordingly? TYIA |
@kunambi I'd hope that |
After installing DDT according to your suggestion, and re-enabling the CachePanel, I see this error on page load:
|
@kunambi you haven't installed the version from main. In the stack trace it's pointing to line 171 of panels/cache.py which on main is not Maybe try uninstalling the toolbar first, then installing as per Matthias' instructions. |
Installed just now via |
Shall we re-open? |
Just like #1769 (comment), that still looks like the non-updated code. Can you try uninstalling the toolbar and then installing from main.zip again? |
Yeah, if Thanks @kunambi for confirming that the fix seems to work! |
Yup, uninstalling and re-installing works. |
Commenting
debug_toolbar.panels.cache.CachePanel
allows DDT to continue to work.Please let me know if you need any more information in order to solve this issue
The text was updated successfully, but these errors were encountered: