Making sure script only runs once instance at a time.

Paul Rubin http
Fri Sep 29 09:26:12 EDT 2006


Hari Sekhon <hpsekhon at googlemail.com> writes:
> Seeing as there doesn't seem to be a good answer to this (or at least
> not one that we have so far some up with) I have decided to fall back
> to my old friend the unix shell. It's as portable as python, but is
> very flexible and fast at doing real things and will tell me if
> another process by this name is running. If so, print msg and
> exit. simple.

Huh?  The obvious way to check for another instance is with a lock
file.  Just open the file and use fcntl to set an exclusive lock.  If
the lock acquisition fails, another instance has the file.



More information about the Python-list mailing list