Making sure script only runs once instance at a time.
Fri Sep 29 18:47:12 CEST 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