summaryrefslogtreecommitdiff
path: root/lib/errorcodes.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/errorcodes.py')
-rw-r--r--lib/errorcodes.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/errorcodes.py b/lib/errorcodes.py
index 12c300f..aa5a723 100644
--- a/lib/errorcodes.py
+++ b/lib/errorcodes.py
@@ -38,11 +38,17 @@ def lookup(code, _cache={}):
return _cache[code]
# Generate the lookup map at first usage.
+ tmp = {}
for k, v in globals().iteritems():
if isinstance(v, str) and len(v) in (2, 5):
- _cache[v] = k
+ tmp[v] = k
- return lookup(code)
+ assert tmp
+
+ # Atomic update, to avoid race condition on import (bug #382)
+ _cache.update(tmp)
+
+ return _cache[code]
# autogenerated data: do not edit below this point.