summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-11-14 00:19:51 -0500
committerChris McDonough <chrism@plope.com>2010-11-14 00:19:51 -0500
commit4a1d0e5fb4d94ca657f85d0ec0f9011485c012a5 (patch)
tree9d0da5a1ccd8c62b735511a79d91728469c1bb1d
parent633700e4c820ba8d0d1652cd799f7119b7a07632 (diff)
downloadpyramid-4a1d0e5fb4d94ca657f85d0ec0f9011485c012a5.tar.gz
pyramid-4a1d0e5fb4d94ca657f85d0ec0f9011485c012a5.tar.bz2
pyramid-4a1d0e5fb4d94ca657f85d0ec0f9011485c012a5.zip
hold a lock while we mutate the registry: it's not safe for more than one thread to mutate it at runtime
-rw-r--r--pyramid/mako_templating.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py
index 7e9ae236f..b63009e2c 100644
--- a/pyramid/mako_templating.py
+++ b/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 @@ class PkgResourceTemplateLookup(TemplateLookup):
return TemplateLookup.get_template(self, uri)
+registry_lock = threading.Lock()
+
def renderer_factory(info):
path = info.name
registry = info.registry
@@ -70,7 +73,12 @@ def renderer_factory(info):
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)