Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #19510 -- Race condition in template loading.

Thanks Kronuz and regebro.
  • Loading branch information...
commit 68905695b897e62b0c18d9edd87171a0eae4e67e 1 parent 0df8ff3
@aaugustin aaugustin authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 django/template/loaders/
6 django/template/loaders/
@@ -43,7 +43,9 @@ def load_template(self, template_name, template_dirs=None):
# 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'):
@@ -55,7 +57,7 @@ def load_template(self, template_name, template_dirs=None):
# 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."
Please sign in to comment.
Something went wrong with that request. Please try again.