Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #19510 -- Race condition in template loading.

Thanks Kronuz and regebro.
  • Loading branch information...
commit 68905695b897e62b0c18d9edd87171a0eae4e67e 1 parent 0df8ff3
Aymeric Augustin authored March 17, 2013

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. 6  django/template/loaders/cached.py
6  django/template/loaders/cached.py
@@ -43,7 +43,9 @@ def load_template(self, template_name, template_dirs=None):
43 43
             # If template directories were specified, use a hash to differentiate
44 44
             key = '-'.join([template_name, hashlib.sha1(force_bytes('|'.join(template_dirs))).hexdigest()])
45 45
 
46  
-        if key not in self.template_cache:
  46
+        try:
  47
+            template = self.template_cache[key]
  48
+        except KeyError:
47 49
             template, origin = self.find_template(template_name, template_dirs)
48 50
             if not hasattr(template, 'render'):
49 51
                 try:
@@ -55,7 +57,7 @@ def load_template(self, template_name, template_dirs=None):
55 57
                     # of the actual template that does not exist.
56 58
                     return template, origin
57 59
             self.template_cache[key] = template
58  
-        return self.template_cache[key], None
  60
+        return template, None
59 61
 
60 62
     def reset(self):
61 63
         "Empty the template cache."

0 notes on commit 6890569

Please sign in to comment.
Something went wrong with that request. Please try again.