[Zope] Locks?

gtk gtk@well.com
Thu, 11 Nov 1999 10:45:02 +1100


[slowly moving this to zope-dev]

> I've got a situation where I'd like to be able to have a mutex lock.
> Unfortunately, I can't use Lock objects out of the thread module as they
> appear to be unpicklable.

Code your own module (for my Shrubbery product I called it ShrubLock) which
has its own acquire() and release() calls. If you need lots of locks, hack
extra stuff into the module and pickle something like an ID. I considered
using an MD5 hash of the object URL.

Note that this is NOT enough to avoid Z2 CONFLICT errors, as Zope does
enough stuff after leaving the methods in your object that there's plenty of
time for another transaction to start on the same object.

This seems to be a fundamental problem with Zope and needs some serious work
on Zope's guts to be resolved. DC apparently advise anyone with
write-intensive needs to use non-ZODB storage.

Unfortunately, as far as I can tell, "write-intensive" devolves to *any* two
modifications at once if you're doing stuff like trying to maintain a
ZCatalog of your web site by having your CatalogAware objects call
reindex_object(). ZCatalog fans, you better use a cron job to trigger
regular re-indexes if your site is going to be at all busy.

Regards,
Garth.

--
<gtk@well.com>