durusmail: quixote-users: (slightly OT) suggestions for inter-process locks?
(slightly OT) suggestions for inter-process locks?
2004-08-23
2004-08-23
Re: (slightly OT) suggestions for inter-process locks?
2004-08-23
(slightly OT) suggestions for inter-process locks?
Graham Fawcett
2004-08-23
I am using SCGI for the very first time with a Quixote application. (A
quick word of thanks to Neil et. al. -- so far, performance is excellent).

I need to implement a lock in a certain block of code, so that only one
process at a time is will be able to execute the restricted block. (Note
this is an inter-process lock, not an inter-thread lock, or I would just
use the standard threading library.)

I'm using ZEO/ZODB for persistence, so I cannot rely on the database to
provide the facility. I need a true lock before attempting the action,
not simply the ability to detect a contention and handle it after the
fact: transactions won't help.

Clearly this isn't an SCGI-specific (or Quixote-specific) issue, but I
wondered what approaches other developers might be using to tackle this
kind of problem? Ideally I'm looking for a cross-platform answer
(whether a library that wraps different facilities for each OS, or a
truly cross-platform approach).

Shared memory/mmap comes to mind, but I confess I'm not sure whether
this will work as needed on Windows. Windows does have sempaphore calls,
though of course they differ from their corresponding Unix calls; that's
another possibility. I'd love to hear if anyone else has already tackled
this.

-- Graham


reply