views:

19

answers:

0

This Question has been asked before: http://stackoverflow.com/questions/2936626/how-to-share-a-dictionary-between-multiple-processes-in-python-without-locking However I have several doubts regarding the program given in the answer:

The issue is that the following step isn't atomic
d['blah'] += 1
Even with locking the answer provided in that question would lead to random results.

Since Process 1 read value of d['blah'] saves it on the stack increments it and again writes it. In Between a Process 2 can read the d['blah'] as well.

Locking means that while d['blah'] is being written or read no other process can access it.

Can someone clarify my doubts?