Making sure script only runs once instance at a time.

Paul Rubin http
Fri Sep 29 12:47:12 EDT 2006


"Tim Williams" <tim at tdw.net> 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.



More information about the Python-list mailing list