Ticket #4444: django_core_servers_basehttp-fix-broken-pipe.diff

File django_core_servers_basehttp-fix-broken-pipe.diff, 1.3 KB (added by trbs, 16 years ago)

django.core.servers.basehttp saner broken pipe message

  • django/core/servers/basehttp.py

    diff -r f3a3129a0a26 django/core/servers/basehttp.py
    a b  
    1313import re
    1414import sys
    1515import urllib
     16import socket
    1617
    1718from django.utils.http import http_date
    1819
     
    487488
    488489    def handle_error(self):
    489490        """Log current error, and send error output to client if possible"""
    490         self.log_exception(sys.exc_info())
     491        exc_type, exc_value = sys.exc_info()[:2]
     492        if issubclass(exc_type, socket.error) and exc_value.args[0]==32:
     493            #self.request_handler.log_request(self.status.split(' ',1)[0], "%s %s" % (self.bytes_sent, exc_value.args[1]))
     494            format = '\"%s\" %s %s %s'
     495            args = (
     496                self.request_handler.requestline,
     497                self.status.split(' ',1)[0],
     498                self.bytes_sent,
     499                exc_value.args[1]
     500            )
     501            sys.stderr.write("[%s] %s\n" % (self.request_handler.log_date_time_string(), format % args))
     502        else:
     503            self.log_exception(sys.exc_info())
    491504        if not self.headers_sent:
    492505            self.result = self.error_output(self.environ, self.start_response)
    493506            self.finish_response()
Back to Top