testing if another instance of a script is already running
mail at timgolden.me.uk
Fri Sep 12 14:35:29 CEST 2008
> 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):
More information about the Python-list