Not working with python 3.10
Opened this issue · 3 comments
Hi,
Recently we upgraded our docker image python version to 3.10 and now our APIs are not working, because of the django-prometheus middleware error. All of the incoming requests are getting failed and the code raises an exception.
sentry is showing problem in this part:
django/core/handlers/base.py in _get_response at line 200
# Complain if the template response middleware returned None (a common error).
self.check_response(
response,
middleware_method,
name='%s.process_template_response' % (
middleware_method.__self__.__class__.__name__,
)
)
try:
response = response.render()
except Exception as e:
It seems there is a problem with middleware_method.__self__.__class__.__name__,
Upgrading the django-prometheus python package to 2.2.0 was not helpful.
Is there anyone who has this problem?
Hi everyone,
I have the same issue but didn't find a solution so far.
I had exactly the same exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/base.py", line 209, in _get_response
middleware_method.__self__.__class__.__name__,
AttributeError: 'function' object has no attribute '__self__'
And the problem, in my case, turned out to be in sentry-sdk and not in django-prometheus. Sentry wraps all middlewares with their own handlers and that was the problem. I updated the django and sentry-sdk packages to the latest versions. And the problem has gone.
I think the problem was related to this function because they actually return the wrapper instead of the real object.
I was on:
django==3.2.16
sentry-sdk==0.16.0
django-prometheus==2.2.0
Upgraded to:
django==4.1.5
sentry-sdk==1.12.1
django-prometheus==2.2.0
Hope this can help someone
i think this bug can be closed, we're running django-prometheus on Python 3.11 without issues here.