为什么mod_wsgi无法写入数据? IOError:写入数据失败

发布于 2024-10-09 12:10:43 字数 702 浏览 0 评论 0原文

可能导致此错误的原因:

$ sudo tail -n 100 /var/log/apache2/error.log'

[Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] mod_wsgi (pid=20343): Exception occurred processing WSGI script '/home/username/public_html/idm.wsgi'.  
[Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] IOError: failed to write data  

这是 WSGI 脚本:

$ cat public_html/idm.wsgi 
import os
import sys

sys.path.append('/home/username/public_html/IDM_app/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

为什么 Django 无法写入数据?

我正在运行 Django 1.2.4

What could be causing this error:

$ sudo tail -n 100 /var/log/apache2/error.log'

[Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] mod_wsgi (pid=20343): Exception occurred processing WSGI script '/home/username/public_html/idm.wsgi'.  
[Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] IOError: failed to write data  

Here is the WSGI script:

$ cat public_html/idm.wsgi 
import os
import sys

sys.path.append('/home/username/public_html/IDM_app/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

Why would Django not be able to write data?

I'm running Django 1.2.4

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

水中月 2024-10-16 12:10:43

该错误(没有任何类型的 Python 回溯)可能是以下内容中描述的问题的变体:

http://code.google.com/p/modwsgi/issues/detail?id=29&can=1

也就是说,当 HTTP 客户端连接在完整响应可以被写回之前丢失时,就会发生这种情况。网络服务器。它仅在 Apache 错误日志中表现为“客户端关闭连接”、“写入数据失败”或“刷新数据失败”IOError。即,WSGI 应用程序看不到,因为数据写入是在 WSGI 应用程序返回之后发生的,因此不能将异常抛出回应用程序来执行任何操作。

问题是,如果您将错误配置为通过电子邮件发送给您,您是否会收到来自 Django 的错误消息。如果你这样做了,那么 Django 中就会发生一些事情。

That error, without any sort of Python traceback, may be a variation on issue described in:

http://code.google.com/p/modwsgi/issues/detail?id=29&can=1

That is, occurs when HTTP client connection is lost before the full response could be written back by the web server. It can manifest as 'client closed connection', 'failed to write data' or 'failed to flush data' IOError in Apache error log only. Ie., not seen by WSGI applicaton because the writing of data is occurring after WSGI application has returned and so can't throw exception back to the application to do anything with.

The question is whether you get an error message from Django if you configure errors to be sent to you in email. If you do, then instead is something happening in Django.

护你周全 2024-10-16 12:10:43

我在使用大量 AJAX 调用的应用程序 (mod_wsgi 3.3) 中遇到同样的问题。有没有已知的解决方案?我想过忽略异常,但这通常不是一个好主意。

更新

实际上,这可能是由于多种原因造成的,但最可能的原因是您正在使用write回调而不是yield您的输出。

我相信这会有所帮助:

http://groups.google.com/group/modwsgi/browse_thread/thread/ c9cc1307bc10cfff

I have the same problem in an application that uses a lot of AJAX calls (mod_wsgi 3.3). Is there any known solution for this? I thought about just ignoring the exception, but that is normally not a very good idea.

UPDATE

Actually, this can be due to several things, but the most probable cause is that you are using the write callback instead of yielding your output.

I believe this will help:

http://groups.google.com/group/modwsgi/browse_thread/thread/c9cc1307bc10cfff

記柔刀 2024-10-16 12:10:43

我在 Digital ocean 中的 python web 应用程序中发现了同样的问题,在认真检查日志文件后,我发现这是我的数据库 mysql 的问题!
问题是由于我的存储空间 (RAM) 不足
所以检查这些问题并解决问题!

`对于 Mysql

这个

希望它会有所帮助

I've found the same problem with my python web app in Digital ocean and after checking the log file seriously I've discovered that It was a problem with my Database mysql !
The problem was due to the fact that I was running out storage (RAM)
So check those question and solve the problem!

`For Mysql

And this

Hope It will help

不甘平庸 2024-10-16 12:10:43

我敢打赌这是一个权限问题。 True 使目标目录/文件普遍可写。然后使该文件归您的 www-data 组(或您的 apache 用户是什么)所有,使其组可写,并确保该文件夹中的任何内容都不敏感,因为这可能是一个安全问题。

I'm wagering it is a permissions issue. True making the target directory/file universally writable. Then make the file owned by your www-data group (or whatever your apache user is), make it group writable, and make sure nothing in that folder is sensitive because this could be a security problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文