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