Django中間件線程安全嗎?我可以做這樣的事情,Django中間件線程安全嗎?
class ThreadsafeTestMiddleware(object):
def process_request(self, request):
self.thread_safe_variable = some_dynamic_value_from_request
def process_response(self, request, response):
# will self.thread_safe_variable always equal to some_dynamic_value_from_request?
更好的可能是將它綁定到request.session(https://docs.djangoproject.com/en/1.3/topics/http/sessions/)。 – Bryan 2011-06-02 20:51:42