I have django 1.3 on the remote server behind Nginx.
If I run django with apache + mod_wsgi, I can watch errors in apache log files. It\'s ok but I\'d like to have
Here is a way to prevent the to print the message to stderr. Just monkey patch the
BaseServer.handle_error function. This is how I do it:
def patch_broken_pipe_error():
"""Monkey Patch BaseServer.handle_error to not write
a stacktrace to stderr on broken pipe.
https://stackoverflow.com/a/7913160"""
import sys
from SocketServer import BaseServer
handle_error = BaseServer.handle_error
def my_handle_error(self, request, client_address):
type, err, tb = sys.exc_info()
# there might be better ways to detect the specific erro
if repr(err) == "error(32, 'Broken pipe')":
# you may ignore it...
logging.getLogger('mylog').warn(err)
else:
handle_error(self, request, client_address)
BaseServer.handle_error = my_handle_error
patch_broken_pipe_error()