[Zope-dev] Re: [Zope] Question about ZODB and threads

Pavlos Christoforou pavlos@gaaros.msrc.sunysb.edu
Thu, 14 Oct 1999 11:50:07 -0400 (EDT)


On Thu, 14 Oct 1999, Martijn Pieters wrote:

> (I moved this to Zope-Dev).

Good idea.

> 
> All this can be found in the ZODB UML model at:
> 
>    http://www.zope.org/Documentation/Developer/Models/ZODB


> especially, Persistent Objects (top left frame) -> Persistent (bottem left 
> frame) and then read the bottom right frame. Don't you love this setup? =)

Yes I like it but I miss the occasional:
'hold onto your butts', 'don't try this at home kids' etc to keep my
spirit up!


I am familiar with the model Martijn, however the whole point of the story
is *not* to register the change with the ZODB. It would be nice if I could
have a temporary in memory storage, accessible from all the threads and
this used to be a simple matter in the pre-concurrent era. Anyway you
have answered my question, ie each thread gets a copy of the class
instance. Do you think I can get away by creating a class that
participates in transactions and where instances of this class modify some
class attribute, like:

class InMemory:

	dict_visible_from_all={}
	
	def set(self,k,v):
		self.dict_visible_from_all[k]=v

	(transaction and garbage collection code ommited)


Are class attributes deepcopied too for each thread? (in which case it
won't solve my problem). If not would such 
operations (ie calling an instance set method) be thread safe?

I also noticed a module for  in memory storage in the ZODB directory, but
I am not sure how to combine the regular FileStorage with the in memory
one. 


Thanks

Pavlos