Bob
Bob

Reputation: 6173

Django OSError: failed to write data

This error happens exactly the same time when logrotate starts it's business (probably logrotate deleted the old file but not created the new one yet), is there any way to fix this?

[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
...

Upvotes: 1

Views: 2470

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58563

The errors indicate you are likely using mod_wsgi daemon mode.

The error:

OSError: failed to write data

is likely because the Apache child worker process which was proxying to the mod_wsgi daemon process was killed while a response was still being written back from the mod_wsgi daemon process via the proxying process. Triggering logrotate could indeed trigger that as it will cause processes to be killed off.

The error:

AssertionError: assert tlock is not None

is because you are using an old mod_wsgi version that doesn't have some changes in it to accommodate that Python 3.4 change internals related to interpreter destruction. You need to upgrade mod_wsgi to get rid of it. In itself it doesn't cause an issue as the process is exiting anyway, but will cause noise in the log files on every restart or shutdown.

Upvotes: 2

Related Questions