Ticket #4909: wsgi-thread-safe-init.patch
File wsgi-thread-safe-init.patch, 1.1 KB (added by , 17 years ago) |
---|
-
django/core/handlers/wsgi.py
6 6 from django import http 7 7 from pprint import pformat 8 8 from shutil import copyfileobj 9 from threading import Lock 9 10 try: 10 11 from cStringIO import StringIO 11 12 except ImportError: … … 176 177 raw_post_data = property(_get_raw_post_data) 177 178 178 179 class WSGIHandler(BaseHandler): 180 initLock = Lock() 179 181 def __call__(self, environ, start_response): 180 182 from django.conf import settings 181 183 182 184 # Set up middleware if needed. We couldn't do this earlier, because 183 185 # settings weren't available. 184 186 if self._request_middleware is None: 185 self.load_middleware() 187 self.initLock.acquire() 188 # Check that we are the first thread to try loading the middleware. 189 if self._request_middleware is None: 190 self.load_middleware() 191 self.initLock.release() 186 192 187 193 dispatcher.send(signal=signals.request_started) 188 194 try: