Re: WeakValueDict and threadsafety

2011-12-10 Thread Darren Dale
On Dec 10, 2:09 pm, Duncan Booth wrote: > Darren Dale wrote: > > On Dec 10, 11:19 am, Duncan Booth > > wrote: > >> Darren Dale wrote: > > def get_data(oid): > >     with reglock: > >         data = registry.get(oid, None) > >         if data is None: > >             data = make_data(oid) > >  

Re: WeakValueDict and threadsafety

2011-12-10 Thread Duncan Booth
Darren Dale wrote: > On Dec 10, 11:19 am, Duncan Booth > wrote: >> Darren Dale wrote: > def get_data(oid): > with reglock: > data = registry.get(oid, None) > if data is None: > data = make_data(oid) > registry[oid] = data > return data > > Does t

Re: WeakValueDict and threadsafety

2011-12-10 Thread 88888 Dihedral
On Sunday, December 11, 2011 1:56:38 AM UTC+8, Darren Dale wrote: > On Dec 10, 11:19 am, Duncan Booth > wrote: > > Darren Dale wrote: > > > I'm concerned that this is not actually thread-safe. When I no longer > > > hold strong references to an instance of data, at some point the > > > garbage co

Re: WeakValueDict and threadsafety

2011-12-10 Thread Darren Dale
On Dec 10, 11:19 am, Duncan Booth wrote: > Darren Dale wrote: > > I'm concerned that this is not actually thread-safe. When I no longer > > hold strong references to an instance of data, at some point the > > garbage collector will kick in and remove that entry from my registry. > > How can I ens

Re: WeakValueDict and threadsafety

2011-12-10 Thread Duncan Booth
Darren Dale wrote: > I'm concerned that this is not actually thread-safe. When I no longer > hold strong references to an instance of data, at some point the > garbage collector will kick in and remove that entry from my registry. > How can I ensure the garbage collection process does not modify