aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/mg_globals.py
diff options
context:
space:
mode:
authorJakob Kramer <jakob.kramer@gmx.de>2012-07-18 19:25:53 +0200
committerJakob Kramer <jakob.kramer@gmx.de>2012-07-18 19:25:53 +0200
commitc80982c7a0d64f01cb4dd44bfde334782f2a72c0 (patch)
tree6804c8d00d90622d1b48be1a4a2c423cd066b01b /mediagoblin/mg_globals.py
parent8464bcc3e86e223db0739101c0b5d914eea225af (diff)
downloadmediagoblin-c80982c7a0d64f01cb4dd44bfde334782f2a72c0.tar.lz
mediagoblin-c80982c7a0d64f01cb4dd44bfde334782f2a72c0.tar.xz
mediagoblin-c80982c7a0d64f01cb4dd44bfde334782f2a72c0.zip
make mg_globals.translations thread-safe
I added mg_globals.thread_scope (an instance of threading.local) and made `translations' an attribute of it.
Diffstat (limited to 'mediagoblin/mg_globals.py')
-rw-r--r--mediagoblin/mg_globals.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/mediagoblin/mg_globals.py b/mediagoblin/mg_globals.py
index 3bd2070d..fffa1dda 100644
--- a/mediagoblin/mg_globals.py
+++ b/mediagoblin/mg_globals.py
@@ -19,6 +19,7 @@ In some places, we need to access the database, public_store, queue_store
import gettext
import pkg_resources
+import threading
#############################
@@ -41,8 +42,11 @@ queue_store = None
# A WorkBenchManager
workbench_manager = None
+# A thread-local scope
+thread_scope = threading.local()
+
# gettext
-translations = gettext.find(
+thread_scope.translations = gettext.find(
'mediagoblin',
pkg_resources.resource_filename(
'mediagoblin', 'translations'), ['en'])