testing if another instance of a script is already running
mail at timgolden.me.uk
Fri Sep 12 14:39:02 CEST 2008
Tim Golden wrote:
> Strato wrote:
>> Hi folks,
>> I want to write some kind of test to check at startup if another
>> instance of my script is already running.
>> I don't want to handle writing of a PID file because it is too
>> Unix/Linux specific way to do this, and I need to keep the code to be
>> I think the better way to achieve this is to use some process control,
>> but I'm a neebie and I don't see how to do this in a safe and clean way.
> There's nothing built in to Python to do this, so you'll
> probably have to roll your own cross-platformness. Of
> course, there's nothing to stop you from writing pid
> files under Windows even if it's not the usual way.
> Or you could just put some conditional code, and use
> the kernel mutex under Windows, which is the generally
> recommended technique. Have a look at this thread,
> for example (among several others):
Sorry, not the best of links to point to. Basically, search
mail.python.org for things like "CreateMutex" and
"single application instance".
More information about the Python-list