[Zope] "Z2 CONFLICT Competing writes" and synchronization woes
Dieter Maurer
dieter@handshake.de
Thu, 31 Aug 2000 21:32:55 +0200 (CEST)
Sean McGrath writes:
> I want to synchronize ...
>
> I tried using the threading module and creating
> a Lock object as a global in the external method.
> This does not help as each request gets allocated its
> own Lock object....
As you observed, each thread gets its own global namespace
for a file containing an external method.
The namespace of a true Python module, however, is shared
by all threads. Therefore, it is a good place for your
lock.
Do the following (or something along similar lines):
* create a properly named subpackage in "lib/python/Shared"
(to avoid name clashes), say "myCompany".
* create a Python module in "myCompany", say "myLock.py".
* create your lock in this module, say "Lock"
* access it in your external method by:
from Shared.myCompany.myLock import Lock
Dieter