mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #4909 -- Fixed a race condition with middleware initialisation in multi-threaded setups. Thanks, colin@owlfish.com.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5868 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
3d012a18ce
commit
6d31e431c3
1
AUTHORS
1
AUTHORS
@ -78,6 +78,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
Bryan Chow <bryan at verdjn dot com>
|
Bryan Chow <bryan at verdjn dot com>
|
||||||
Michal Chruszcz <troll@pld-linux.org>
|
Michal Chruszcz <troll@pld-linux.org>
|
||||||
Ian Clelland <clelland@gmail.com>
|
Ian Clelland <clelland@gmail.com>
|
||||||
|
colin@owlfish.com
|
||||||
crankycoder@gmail.com
|
crankycoder@gmail.com
|
||||||
Pete Crosier <pete.crosier@gmail.com>
|
Pete Crosier <pete.crosier@gmail.com>
|
||||||
Matt Croydon <http://www.postneo.com/>
|
Matt Croydon <http://www.postneo.com/>
|
||||||
|
@ -6,6 +6,7 @@ from django.utils.encoding import force_unicode
|
|||||||
from django import http
|
from django import http
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from shutil import copyfileobj
|
from shutil import copyfileobj
|
||||||
|
from threading import Lock
|
||||||
try:
|
try:
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -176,13 +177,19 @@ class WSGIRequest(http.HttpRequest):
|
|||||||
raw_post_data = property(_get_raw_post_data)
|
raw_post_data = property(_get_raw_post_data)
|
||||||
|
|
||||||
class WSGIHandler(BaseHandler):
|
class WSGIHandler(BaseHandler):
|
||||||
|
initLock = Lock()
|
||||||
|
|
||||||
def __call__(self, environ, start_response):
|
def __call__(self, environ, start_response):
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
# Set up middleware if needed. We couldn't do this earlier, because
|
# Set up middleware if needed. We couldn't do this earlier, because
|
||||||
# settings weren't available.
|
# settings weren't available.
|
||||||
|
if self._request_middleware is None:
|
||||||
|
self.initLock.acquire()
|
||||||
|
# Check that middleware is still uninitialised.
|
||||||
if self._request_middleware is None:
|
if self._request_middleware is None:
|
||||||
self.load_middleware()
|
self.load_middleware()
|
||||||
|
self.initLock.release()
|
||||||
|
|
||||||
dispatcher.send(signal=signals.request_started)
|
dispatcher.send(signal=signals.request_started)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user