Chris McDonough
2010-11-14 4a1d0e5fb4d94ca657f85d0ec0f9011485c012a5
hold a lock while we mutate the registry: it's not safe for more than one thread to mutate it at runtime
1 files modified
10 ■■■■■ changed files
pyramid/mako_templating.py 10 ●●●●● patch | view | raw | blame | history
pyramid/mako_templating.py
@@ -1,4 +1,5 @@
import os
import threading
from zope.interface import implements
from zope.interface import Interface
@@ -51,6 +52,8 @@
        return TemplateLookup.get_template(self, uri)
registry_lock = threading.Lock()
def renderer_factory(info):
    path = info.name
    registry = info.registry
@@ -70,7 +73,12 @@
                                           module_directory=module_directory,
                                           input_encoding=input_encoding,
                                           filesystem_checks=reload_templates)
        registry.registerUtility(lookup, IMakoLookup)
        registry_lock.acquire()
        try:
            registry.registerUtility(lookup, IMakoLookup)
        finally:
            registry_lock.release()
    return MakoLookupTemplateRenderer(path, lookup)