On 29 Sep 2006 09:47:12 -0700, Paul Rubin
<"http://phr.cx"@nospam.invalid> wrote:
> "Tim Williams" <[EMAIL PROTECTED]> writes:
> > My reply was in response to a post that mentioned a known problem with
> > this,  what happens when the previously running program doesn't exit
> > gracefully, and leaves the directory in place ??
>
> Don't use the presence or absence of a file as a lock.  Have the file
> there all the time, and have the app open it and use fcntl to get an
> exclusive kernel lock on the file descriptor.  That lock should go
> away when the process exits, so you don't have to worry about cleaning
> it up.  See "man fcntl" for details.

That's the same kind of principle as my posted snippet,  it doesn't
rely on the file's presence or absence as such.  It only cares when
the file exists *and* is held open by another process.    When the
process exits,  the lock ends without needing to clean up.

It works on Windows, but that doesn't help the OP :)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to