Saturday, May 30, 2020

Re: Possible Bug? AttributeError: 'HttpResponse' object has no attribute '_resource_closers'

Thanks for the reply, my friend. Unfortunately, no new middleware has been added. Some folks have said clearing the Django cache(s) worked, but it hasn't for me.

I've long been a mod_wsgi user, but I think it is time to move on to gunicorn, so I've started moving in that direction rather than sinking a lot more time here.

On Saturday, May 16, 2020 at 5:02:32 PM UTC-4, jlgimeno71 wrote:


On Sat, May 16, 2020 at 12:06 PM Tim Allen <fli...@peregrinesalon.com> wrote:
I posted this to Stack Overflow first, thinking it might be a problem with `mod_wsgi`, but people using Gunicorn have seen the issue too. Here's a link to the question on Stack Overflow:

https://stackoverflow.com/questions/61295971/django-3-0-5-with-mod-wsgi-attributeerror-httpresponse-object-has-no-attribu

Unfortunately, purging my cache hasn't fixed the problem like it did for a commenter on the question, so I'm asking here for amplification. Here's the text of the post:

I'm getting an error when I deploy Django 3.0.5 under mod_wsgi:  AttributeError: 'HttpResponse' object has no attribute '_resource_closers'. I'm running:
  • Python: 3.6.8
  • Django: 3.0.5
  • Apache: 2.4.6
  • mod_wsgi: 4.6.2

Here's the basics of the view causing the error; nothing too exotic (I've simplified the code around meetings_struct):


class MeetingsAPIView(MeetingsBaseView):      def get(self, request, *args, **kwargs):          meetings = self.get_meetings()          meetings_struct = []            for meeting in meetings:              meetings_struct.append({                  "id": meeting.id,                  "name": meeting.title,                  "slug": meeting.slug,              })            return HttpResponse(meetings_struct, content_type="application/json")


If I activate the venv and use runserver manually on the server on port 80, the same view does not give an error. When the same code and venv are running under Apache, here's the error from Apache's logs:


[Sat Apr 18 16:11:30.683980 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] mod_wsgi (pid=4154): Exception occurred processing WSGI script '/var/django/sites/mysite-prod/config/wsgi.py'.  [Sat Apr 18 16:11:30.684834 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] Traceback (most recent call last):  [Sat Apr 18 16:11:30.684891 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]   File "/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/wsgi.py", line 133, in __call__  [Sat Apr 18 16:11:30.684903 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]     response = self.get_response(request)  [Sat Apr 18 16:11:30.684925 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]   File "/var/django/sites/mysite-prod/venv/lib64/python3.6/site-packages/django/core/handlers/base.py", line 76, in get_response  [Sat Apr 18 16:11:30.684933 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397]     response._resource_closers.append(request.close)  [Sat Apr 18 16:11:30.684964 2020] [wsgi:error] [pid 4154] [remote 100.19.146.139:54397] AttributeError: 'HttpResponse' object has no attribute '_resource_closers'


I've rolled back to a previous version that works, running Django 2.2; the rest of the stack is the same. This one has me puzzled, as using the same deployed code with the same venv that Apache is configured to use works fine under runserver, but errors with mod_wsgi. I've tried stopping and starting Apache, running the publish process again for a fresh venv and code base, and even rebooting the server. The same error occurs, but only under Apache / mod_wsgi.


Any ideas? I'm puzzled!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0381e998-321e-489f-abe1-853b6997930f%40googlegroups.com.

Tim,

Shot in the dark:  Did you add any middleware by chance?

-Jorge

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f80c3888-eaac-48da-adaf-1862e1d4be5f%40googlegroups.com.

No comments:

Post a Comment