Do Managers in Python Multiprocessing module lock the shared data?

Posted by AnonProcess on Stack Overflow See other posts from Stack Overflow or by AnonProcess
Published on 2010-06-06T07:24:24Z Indexed on 2010/06/06 7:32 UTC
Read the original article Hit count: 190

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about python

Related posts about multiprocessing