I'm not sure if that is a very old way of doing it, which is why I was reluctant to do it. My way actually uses the process list of the os (linux) and counts the number of instances. If it is more than 0 then another process is running and the script exits gracefully.

Also, apart from the fact the using lockfiles feels a bit 1970s, I have found that in real usage of other programs within the company that use lockfiles, it sometimes causes a bit of troubleshooting time when it stops working due to a stale lockfile. This especially happens when the program is killed, the lockfile remains and causes minor annoyance (to somebody who knows that is, more annoyance to somebody who doesn't).

-h
Hari Sekhon


Paul Rubin wrote:
Hari Sekhon <[EMAIL PROTECTED]> 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.
  


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to