summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2011-12-30 12:55:08 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2011-12-30 12:55:08 +0000
commitfa226cd740f1349383d5e8399dc8a5255b70f07a (patch)
treeefd10957b58f8358e2ace0b39a6197a689129653
parentca984aa50a4ac9278c8828c8fa178e678baa77a1 (diff)
Fixed #17303 -- Ensured the list of template loaders is fully loaded before it is cached. Thanks andrey DOT gtx AT gmail DOT com for the report and patch, and Anssi Kääriäinen for the review.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17295 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/template/loaders/cached.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py
index 3ed9cf3bbf..4c25acd599 100644
--- a/django/template/loaders/cached.py
+++ b/django/template/loaders/cached.py
@@ -19,8 +19,12 @@ class Loader(BaseLoader):
def loaders(self):
# Resolve loaders on demand to avoid circular imports
if not self._cached_loaders:
+ # Set self._cached_loaders atomically. Otherwise, another thread
+ # could see an incomplete list. See #17303.
+ cached_loaders = []
for loader in self._loaders:
- self._cached_loaders.append(find_template_loader(loader))
+ cached_loaders.append(find_template_loader(loader))
+ self._cached_loaders = cached_loaders
return self._cached_loaders
def find_template(self, name, dirs=None):