From fa226cd740f1349383d5e8399dc8a5255b70f07a Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 30 Dec 2011 12:55:08 +0000 Subject: 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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.djangoproject.com/svn/django/trunk@17295 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/template/loaders/cached.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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): -- cgit v1.3