[Zope-dev] Transaction question

Shane Hathaway shane@digicool.com
Mon, 28 Aug 2000 10:47:31 -0400


Johan Carlsson wrote:
> 
> I just want to check if things work the way I think (hope) it does.
> 
> In a transaction, are objects attributes safe from other threads.
> 
> self._v_mytemp in my request does not conflict with other requests?

This is correct (or it's supposed to be.)  Each thread has its own copy
of the objects, so in most cases, all instance attributes are thread
safe.

> (I suppose the have to be otherwise REQUEST's would interfere with each other.)
> 
> I know that _v_* attributes aren't persistent but do they remain active in memory
> and there by accessible to other requests after the transaction commit?

They do remain after the commit.  But when the objects are removed from
the in-memory cache the _v_* attributes will vanish.

> (I suppose class attributes needs to be protected to be thread-safe?
>  Does anybody have an example how to do that?)

You can use allocate_lock() to accomplish thread safety with class
attributes.

Shane