]> git.openstreetmap.org Git - osqa.git/commitdiff
Make RequestHolder thread-safe
authorAttila-Mihaly Balazs <dify.ltd@gmail.com>
Thu, 16 Jan 2014 10:05:06 +0000 (12:05 +0200)
committerAttila-Mihaly Balazs <dify.ltd@gmail.com>
Thu, 16 Jan 2014 10:05:06 +0000 (12:05 +0200)
forum/__init__.py

index 51c0c431c26bb68ed2ccf20fd1374e6a2239938d..fa60dba1d3f1cec275f057e83ae5c545f1bb4476 100644 (file)
@@ -1,5 +1,15 @@
+import threading
+
+
 class RequestHolder(object):
-    def __init__(self):
-        self.request = None
+    _requests = threading.local()
+
+    @property
+    def request(self):
+        return self._requests.request
+
+    @request.setter
+    def request(self, value):
+        self._requests.request = value
 
-REQUEST_HOLDER = RequestHolder()
\ No newline at end of file
+REQUEST_HOLDER = RequestHolder()