Ticket #14640: timing.patch

File timing.patch, 1.2 KB (added by Vaughn Koch, 14 years ago)

Change to basehttp.py to time an HTTP query and display it in the dev server log.

  • django/core/servers/basehttp.py

     
    1414import stat
    1515import sys
    1616import urllib
     17import time
    1718
    1819from django.core.management.color import color_style
    1920from django.utils.http import http_date
     
    267268        self.base_env = environ
    268269        self.wsgi_multithread = multithread
    269270        self.wsgi_multiprocess = multiprocess
     271        self.start_time = time.time()
    270272
    271273    def run(self, application):
    272274        """Invoke the application"""
     
    447449
    448450    def close(self):
    449451        try:
    450             self.request_handler.log_request(self.status.split(' ',1)[0], self.bytes_sent)
     452            time_elapsed = time.time() - self.start_time
     453            code = self.status.split(' ',1)[0]
     454            size = self.bytes_sent
     455            self.request_handler.log_message('"%s" %s %s %0.2f',
     456                    self.request_handler.requestline, str(code), str(size),
     457                                        time_elapsed)
    451458        finally:
    452459            try:
    453460                if hasattr(self.result,'close'):
Back to Top