Threads modify "global" variable -- asking for trouble?

Terry Reedy tjreedy at udel.edu
Fri Mar 17 00:35:52 EST 2006


"J Rice" <rice.jeffrey at gmail.com> wrote in message 
news:1142568360.823100.3460 at i40g2000cwc.googlegroups.com...
>
> My apologizes, I missed the newish FAQ entry on this.  The addrbl()
> method looks like this:
>
> def addRBL(self, testname, result, info=""):
>        self.testresultsRBL[testname] = result, info
>
> So according to the FAQ, D[x] = y, where D is a dictionary, is atomic
> and therefore thread-safe.  Right?

I believe an alternative, mentioned elsewhere by Tim Peters, is for workers 
to send results (here (testname,result,info) ) back in a results queue read 
by the main thread.

tjr



tjr






More information about the Python-list mailing list