[Zope-dev] Re: ComputedAttribute
Martijn Pieters
mj@digicool.com
Thu, 11 Jan 2001 09:01:09 +0100
On Wed, Jan 10, 2001 at 11:37:55PM -0000, Chris Withers wrote:
> > Chris Withers writes:
>
> > > ....with this class, your_attribute isn't going to play in Persistence,
> > > is it? (so I can update it lots without worrying about ZODB size
> > > growing... :-)
>
> > But, as I understand it, it is only updated in the thread
> > that did the update. Your next request may get a different
> > thread and see a different value.
>
> Huh?
>
> If I change self._v_your_attribute it's only going to get updated in one
> thread?
> That's a bit sucky :-S
>
> Doesn't matter in this _particular_ case 'cos this var gets set at the start
> of every request, but I'm a bit concerned about its general use...
>
> any help is good help :-)
The whole threading spiel in Zope works because of ZODB persistence; any
thread accessing an object whose variables have been changed has to retry
with a fresh copy from the ODB.
But because _v_* variables don't get pickled, another thread will never
see them. If you want non-persisting (volatile) variables shared between
threads, you'll have to devise your own mechanism for assuring the
thread-safety of those variables.
--
Martijn Pieters
| Software Engineer mailto:mj@digicool.com
| Digital Creations http://www.digicool.com/
| Creators of Zope http://www.zope.org/
---------------------------------------------