summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-03-17 23:56:07 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-03-17 23:56:07 +0100
commit68905695b897e62b0c18d9edd87171a0eae4e67e (patch)
tree76d87cefbde095f48b47b474299b292037687556
parent0df8ff3dbec8e3ce1b699ee23e36fc211e44a612 (diff)
Fixed #19510 -- Race condition in template loading.
Thanks Kronuz and regebro.
-rw-r--r--django/template/loaders/cached.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py
index fb987a5e3a..c61045de06 100644
--- a/django/template/loaders/cached.py
+++ b/django/template/loaders/cached.py
@@ -43,7 +43,9 @@ class Loader(BaseLoader):
# If template directories were specified, use a hash to differentiate
key = '-'.join([template_name, hashlib.sha1(force_bytes('|'.join(template_dirs))).hexdigest()])
- if key not in self.template_cache:
+ try:
+ template = self.template_cache[key]
+ except KeyError:
template, origin = self.find_template(template_name, template_dirs)
if not hasattr(template, 'render'):
try:
@@ -55,7 +57,7 @@ class Loader(BaseLoader):
# of the actual template that does not exist.
return template, origin
self.template_cache[key] = template
- return self.template_cache[key], None
+ return template, None
def reset(self):
"Empty the template cache."