[Zope] Sharing global data between threads / locking a method

Jonathan dev101 at magma.ca
Mon Jun 27 11:33:20 EDT 2005


----- Original Message ----- 
From: "Pascal Peregrina" <Pperegrina at lastminute.com>


>I think that storing an "isMyProcessingStarted" property would not work,
> because the transaction that modifies the property value would not be
> committed until the long processing is done, so when the next transaction
> that reads this value starts (if this happens before the previous one has
> finished), it would still see the old value.

Interesting thought... you would have to do a test to see what gets commited 
and when.   I think you are right about the property field on a zope object 
not getting 'committed' to the zodb until the transaction completes, however 
I am not sure when changes are made to 'temp_folder' objects as they are not 
committed to the zodb (ie. do changes to temp_folder objects happen 
immediately or are temp_folder changes also tied in to the committment 
machinery)?   Some testing would have to be done to confirm this.

There is a quick solution though:  include the following command in your 
external method after your code that modifies the 'flag':
                get_transaction().commit()

This will invoke the zope commitment machinery immediately.


Jonathan





More information about the Zope mailing list