mirror of
https://github.com/django/daphne.git
synced 2025-07-10 16:02:18 +03:00
Remove lazy loading of middleware
This mirrors the equivalent change in Django itsef. See:
https://code.djangoproject.com/ticket/26452
99bb7fcc18
This commit is contained in:
parent
37923c3674
commit
28e897d9bc
|
@ -7,7 +7,6 @@ import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from threading import Lock
|
|
||||||
|
|
||||||
from django import http
|
from django import http
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -168,20 +167,16 @@ class AsgiHandler(base.BaseHandler):
|
||||||
a HTTP request)
|
a HTTP request)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
initLock = Lock()
|
|
||||||
request_class = AsgiRequest
|
request_class = AsgiRequest
|
||||||
|
|
||||||
# Size to chunk response bodies into for multiple response messages
|
# Size to chunk response bodies into for multiple response messages
|
||||||
chunk_size = 512 * 1024
|
chunk_size = 512 * 1024
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(AsgiHandler, self).__init__(*args, **kwargs)
|
||||||
|
self.load_middleware()
|
||||||
|
|
||||||
def __call__(self, message):
|
def __call__(self, message):
|
||||||
# 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()
|
|
||||||
# Set script prefix from message root_path
|
# Set script prefix from message root_path
|
||||||
set_script_prefix(message.get('root_path', ''))
|
set_script_prefix(message.get('root_path', ''))
|
||||||
signals.request_started.send(sender=self.__class__, message=message)
|
signals.request_started.send(sender=self.__class__, message=message)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user