Django OSError:无法写入数据

时间:2014-09-10 06:18:02

标签: django

当logrotate启动它的业务时,这个错误发生的时间完全相同(可能是logrotate删除了旧文件但尚未创建新文件),有什么方法可以解决这个问题吗?

[Tue Sep 09 19:40:02 2014] [error] [client 127.0.0.1] mod_wsgi (pid=11228): Exception occurred processing WSGI script '/var/www/example.com/project/wsgi.py'.
[Tue Sep 09 19:40:02 2014] [error] [client 127.0.0.1] OSError: failed to write data
[Tue Sep 09 19:40:02 2014] [error] Exception ignored in: <module 'threading' from '/opt/python3/lib/python3.4/threading.py'>
[Tue Sep 09 19:40:02 2014] [error] Traceback (most recent call last):
[Tue Sep 09 19:40:02 2014] [error]   File "/opt/python3/lib/python3.4/threading.py", line 1289, in _shutdown
[Tue Sep 09 19:40:02 2014] [error] Exception ignored in: <module 'threading' from '/opt/python3/lib/python3.4/threading.py'>
[Tue Sep 09 19:40:02 2014] [error] Traceback (most recent call last):
[Tue Sep 09 19:40:02 2014] [error]   File "/opt/python3/lib/python3.4/threading.py", line 1289, in _shutdown
[Tue Sep 09 19:40:02 2014] [error]     assert tlock is not None
[Tue Sep 09 19:40:02 2014] [error] AssertionError: 
[Tue Sep 09 19:40:02 2014] [error]     assert tlock is not None
[Tue Sep 09 19:40:02 2014] [error] AssertionError: 
Exception ignored in: <bound method Signal._remove_receiver of <django.dispatch.dispatcher.Signal object at 0x7fd6201f86a0>>
Traceback (most recent call last):
  File "/opt/python3/lib/python3.4/site-packages/django/dispatch/dispatcher.py", line 276, in _remove_receiver
NameError: name 'len' is not defined
Exception ignored in: <bound method Signal._remove_receiver of <django.dispatch.dispatcher.Signal object at 0x7fd6204be550>>
Traceback (most recent call last):
  File "/opt/python3/lib/python3.4/site-packages/django/dispatch/dispatcher.py", line 276, in _remove_receiver
NameError: name 'len' is not defined
...

1 个答案:

答案 0 :(得分:1)

错误表明您可能正在使用mod_wsgi守护程序模式。

错误:

OSError: failed to write data

可能是因为代理到mod_wsgi守护程序进程的Apache子进程进程被杀死,而响应仍然是通过代理进程从mod_wsgi守护程序进程写回来的。触发logrotate确实可以触发,因为它会导致进程被终止。

错误:

AssertionError: assert tlock is not None

是因为您正在使用一个旧的mod_wsgi版本,该版本没有对其进行一些更改以适应与解释器销毁相关的Python 3.4更改内部。你需要升级mod_wsgi来摆脱它。本身它不会导致问题,因为该过程无论如何都会退出,但每次重启或关闭时都会在日志文件中产生噪音。