From fa226cd740f1349383d5e8399dc8a5255b70f07a Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 30 Dec 2011 12:55:08 +0000 Subject: [PATCH] =?UTF-8?q?Fixed=20#17303=20--=20Ensured=20the=20list=20of?= =?UTF-8?q?=20template=20loaders=20is=20fully=20loaded=20before=20it=20is?= =?UTF-8?q?=20cached.=20Thanks=20andrey=20DOT=20gtx=20AT=20gmail=20DOT=20c?= =?UTF-8?q?om=20for=20the=20report=20and=20patch,=20and=20Anssi=20K=C3=A4?= =?UTF-8?q?=C3=A4ri=C3=A4inen=20for=20the=20review.?= 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):