[Zope] Sharing global data between threads / locking a method
Dieter Maurer
dieter at handshake.de
Mon Jun 27 14:05:28 EDT 2005
Max M wrote at 2005-6-27 15:53 +0200:
> ...
>So in a external method/module I have a function like this:
>
>BUSY_STATE = 0
>def sync_in_progress(busy=None):
> global BUSY_STATE
> if busy is None:
> return BUSY_STATE
> else:
> BUSY_STATE = busy
Note that this is likely to fail.
The module containing an External Method is maintained in the
ZODB cache. As a consequence, each worker gets its own copy
and you cannot synchronize via global variables of such modules.
Use a true Python module (note that Zope does not import
the source file of an External Method; therefore, it is
not inside a module in the Python sense) when you need
synchronization via global module level variables.
--
Dieter
More information about the Zope
mailing list