[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

When to lock data items returned by multiprocessing.Manager?

Veloz

3/3/2010 4:39:00 PM

So I'm using a multiprocessing.Manager instance in my main app and
asking it to create a dictionary, which I am providing to instances of
the application that I'm forking off with Process.

The Processes and main app will be reading/writing to the dictionary.

It's not clear to me what I have to "lock" and what I don't have to
lock. Any ideas?

I'm thinking that what Manager brings to the table is the ability to
share the dictionary but it may not provide anything to control
concurrent access to it, and thus I should lock all operations I
perform on it.. But I don't know this for a fact. Any input is
welcomed on this!!

Michael
1 Answer

aahz

3/15/2010 7:57:00 PM

0

In article <4428d674-7fa7-4095-a93d-75ea31a81d9a@15g2000yqi.googlegroups.com>,
Veloz <michaelveloz@gmail.com> wrote:
>
>So I'm using a multiprocessing.Manager instance in my main app and
>asking it to create a dictionary, which I am providing to instances of
>the application that I'm forking off with Process.
>
>The Processes and main app will be reading/writing to the dictionary.
>
>It's not clear to me what I have to "lock" and what I don't have to
>lock. Any ideas?

The way I deal with it is by making sure each key is only updated by a
single process.
--
Aahz (aahz@pythoncraft.com) <*> http://www.python...

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer