On Tue, Jun 15, 2010 at 7:04 PM, Vishal Rana <ranavis...@gmail.com> wrote: > Hi, > A module level dictionary 'd' and is accessed by different threads/requests > in a django web application. I need to update 'd' every minute with a new > data and the process takes about 5 seconds. > What could be best solution where I want the users to get either the old > value or the new and nothing in between. > I can think of a solution where a temp dictionary is constructed with a new > data and assigned to 'd' but now sure how this works! > Appreciate your ideas. > Thanks
Constructing a new dictionary out-of-place and then assigning it to the proper name sounds perfectly reasonable to me. Since the assignment operation is atomic, you shouldn't even need to guard it with a mutex. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list