From: Attila-Mihaly Balazs Date: Thu, 16 Jan 2014 10:05:06 +0000 (+0200) Subject: Make RequestHolder thread-safe X-Git-Tag: live~28^2~1^2 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/62ed3da3a2ef892a787a24ece991b0bf9b39e112?ds=sidebyside Make RequestHolder thread-safe --- diff --git a/forum/__init__.py b/forum/__init__.py index 51c0c43..fa60dba 100644 --- a/forum/__init__.py +++ b/forum/__init__.py @@ -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()