Ticket #10470: thread-safe-handlers.diff

File thread-safe-handlers.diff, 2.4 KB (added by tdterry, 16 years ago)

Patch against r10030 to solve multi-thread issues with the core handlers

  • django/core/handlers/base.py

     
    2424        """
    2525        from django.conf import settings
    2626        from django.core import exceptions
    27         self._request_middleware = []
    28         self._view_middleware = []
    29         self._response_middleware = []
    30         self._exception_middleware = []
     27        _request_middleware = []
     28        _view_middleware = []
     29        _response_middleware = []
     30        _exception_middleware = []
    3131        for middleware_path in settings.MIDDLEWARE_CLASSES:
    3232            try:
    3333                dot = middleware_path.rindex('.')
     
    4949                continue
    5050
    5151            if hasattr(mw_instance, 'process_request'):
    52                 self._request_middleware.append(mw_instance.process_request)
     52                _request_middleware.append(mw_instance.process_request)
    5353            if hasattr(mw_instance, 'process_view'):
    54                 self._view_middleware.append(mw_instance.process_view)
     54                _view_middleware.append(mw_instance.process_view)
    5555            if hasattr(mw_instance, 'process_response'):
    56                 self._response_middleware.insert(0, mw_instance.process_response)
     56                _response_middleware.insert(0, mw_instance.process_response)
    5757            if hasattr(mw_instance, 'process_exception'):
    58                 self._exception_middleware.insert(0, mw_instance.process_exception)
     58                _exception_middleware.insert(0, mw_instance.process_exception)
    5959
     60        self._view_middleware = _view_middleware
     61        self._response_middleware = _response_middleware
     62        self._exception_middleware = _exception_middleware
     63
     64        # this must be last because __call__ in the child class
     65        # will test it to know if load_middleware is complete
     66        self._request_middleware = _request_middleware
     67
    6068    def get_response(self, request):
    6169        "Returns an HttpResponse object for the given HttpRequest"
    6270        from django.core import exceptions, urlresolvers
  • AUTHORS

     
    449449    Mykola Zamkovoi <nickzam@gmail.com>
    450450    Jarek Zgoda <jarek.zgoda@gmail.com>
    451451    Cheng Zhang
     452    Travis Terry <tdterry7@gmail.com>
    452453
    453454A big THANK YOU goes to:
    454455
Back to Top