Python Django 3.0.5,带有mod_wsgi:AttributeError:';HttpResponse';对象没有属性'_资源关闭器';
我在Python Django 3.0.5,带有mod_wsgi:AttributeError:';HttpResponse';对象没有属性'_资源关闭器';,python,django,apache,mod-wsgi,Python,Django,Apache,Mod Wsgi,我在mod\u wsgi下部署Django 3.0.5时出错:AttributeError:'HttpResponse'对象没有属性'\u resource\u closer'。我在跑步: Python:3.6.8 Django:3.0.5 Apache:2.4.6 mod_wsgi:4.6.2 下面是导致错误的视图的基本信息;没有什么特别之处(我已经简化了meetings\u struct)周围的代码: class MeetingsAPIView(会议基本视图): def get(自我、请
mod\u wsgi
下部署Django 3.0.5时出错:AttributeError:'HttpResponse'对象没有属性'\u resource\u closer'
。我在跑步:
- Python:3.6.8
- Django:3.0.5
- Apache:2.4.6
- mod_wsgi:4.6.2
meetings\u struct
)周围的代码:
class MeetingsAPIView(会议基本视图):
def get(自我、请求、*args、**kwargs):
会议=自我。获取会议()
会议结构=[]
在会议中开会:
会议结构附加({
“id”:meeting.id,
“名称”:meeting.title,
“slug”:meeting.slug,
})
返回HttpResponse(meetings\u struct,content\u type=“application/json”)
如果我在端口80上的服务器上手动激活venv
并使用runserver
,相同的视图不会给出错误。当相同的代码和venv
在Apache下运行时,以下是Apache日志中的错误:
[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'
我回到了以前的版本,运行Django 2.2;堆栈的其余部分是相同的。这一点让我感到困惑,因为使用相同的部署代码和Apache配置为使用的相同的venv
在runserver
下运行良好,但在mod_wsgi
中出现错误
我尝试过停止和启动Apache,再次运行发布过程以获得新的venv
和代码库,甚至重新启动服务器。同样的错误也会发生,但仅在Apache/mod_wsgi下发生
有什么想法吗?我很困惑 我在使用Django3.0.6、Python3.8.2和Gunicorn时也遇到同样的问题。您正在使用sentry sdk吗?就我而言,问题似乎是由哨兵整合引起的。不幸的是,我不是。这是一个非常普通的安装,带有Wagtail的Django,有几个JSON端点用于ReactJS应用程序。我仍然没有找到解决办法——我正在转向Gunicorn,因为我一直想朝着这个方向前进。你是最新/最棒的Gunicorn吗?不知道这是否与异步相关。今天早些时候也有同样的问题,对我来说,缓存视图响应可能是个问题。清除memcache并开始工作。我正在使用最新的Gunicorn(20.0.4),我认为这与异步无关。为了解决这个问题,我不得不降级到Django 2.2.12。(LTS)。@illagrenan你和哨兵解决问题了吗?在我的例子中,问题似乎也是由Sentry引起的:
文件“C:\venv\lib\site packages\Sentry\u sdk\integrations\django\\uuuuuu init\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu。刚刚从2.2.3更新到Django 3.1.5。