1 2 3 4 5 6 | """
Snippet removed - this approach is *NOT* thread safe.
Snippet removed - this approach is *NOT* thread safe.
Snippet removed - this approach is *NOT* thread safe.
Snippet removed - this approach is *NOT* thread safe.
"""
|
More like this
- GlobalRequest middleware by myq 5 months, 3 weeks ago
- Improved Pickled Object Field by taavi223 3 years, 9 months ago
- Effective content caching for mass-load site using redirect feature by nnseva 1 year, 10 months ago
- RequiredNullBooleanField by wwu.housing 4 years, 2 months ago
- Add get_addr() method to request object by nikmolnar 5 months, 1 week ago
Comments
This is not only slightly frowned upon, it might very well not work the way you expect it to. If your web server executes multiple threads per python process, threads will overwrite eachother's request object since global variables are shared among threads. If you really want to do this use thread-locals. But that's a bad idea as well: http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
Generally, if you need the request (or user) object somewhere, pass it as a parameter. If that's not possible then you are either doing something wrong or missing the solution to your problem. Most likely, thread-locals aren't the best one.
#