Ticket #19510: #19510-thread_safe_template_cache.3.diff

File #19510-thread_safe_template_cache.3.diff, 705 bytes (added by regebro, 12 years ago)

Simpler way to avoid race.

  • django/template/loaders/cached.py

    diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py
    index 4c25acd..1036263 100644
    a b class Loader(BaseLoader):  
    4242            # If template directories were specified, use a hash to differentiate
    4343            key = '-'.join([template_name, hashlib.sha1('|'.join(template_dirs)).hexdigest()])
    4444
    45         if key not in self.template_cache:
     45        try:
     46            return self.template_cache[key], None
     47        except KeyError:
    4648            template, origin = self.find_template(template_name, template_dirs)
    4749            if not hasattr(template, 'render'):
    4850                try:
Back to Top