How do I force a single instance of a python app?

Joshua Muskovitz josh at open.com
Tue Oct 24 15:42:02 EDT 2000


I need to prevent multiple copies of a python app from running
simultaneously on a single machine.  In Windows and C++, this is done with
sending custom window messages to all top level windows, or using some other
kind of scheme.

I'm looking for a platform neutral way to do this for my python apps -- the
second instance should somehow detect the first instance and should quietly
kill itself.  It does not need to notify the first instance of anything.
Initial target platforms are Solaris and NT, but others will follow, so a
generic solution would be the best.  File existence is a bad solution
because the first instance might (possibly) terminate before it could delete
the file.  I need a semaphore which will absolutely go away when the first
instance dies, or else a way to reliably probe to see if the first instance
exists on the fly.

Suggestions gratefully accepted!

-- josh




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list