From 62ed3da3a2ef892a787a24ece991b0bf9b39e112 Mon Sep 17 00:00:00 2001 From: Attila-Mihaly Balazs Date: Thu, 16 Jan 2014 12:05:06 +0200 Subject: [PATCH] Make RequestHolder thread-safe --- forum/__init__.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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() -- 2.39.5