1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #26452 -- Loaded middleware on server start rather than on first request.

This commit is contained in:
David Evans
2016-04-03 14:43:51 +01:00
committed by Tim Graham
parent 23aa700b78
commit 99bb7fcc18
4 changed files with 15 additions and 24 deletions

View File

@@ -6,7 +6,6 @@ import logging
import re
import sys
from io import BytesIO
from threading import Lock
from django import http
from django.conf import settings
@@ -147,18 +146,13 @@ class WSGIRequest(http.HttpRequest):
class WSGIHandler(base.BaseHandler):
initLock = Lock()
request_class = WSGIRequest
def __call__(self, environ, start_response):
# Set up middleware if needed. We couldn't do this earlier, because
# settings weren't available.
if self._request_middleware is None:
with self.initLock:
# Check that middleware is still uninitialized.
if self._request_middleware is None:
self.load_middleware()
def __init__(self, *args, **kwargs):
super(WSGIHandler, self).__init__(*args, **kwargs)
self.load_middleware()
def __call__(self, environ, start_response):
set_script_prefix(get_script_name(environ))
signals.request_started.send(sender=self.__class__, environ=environ)
try: