testing if another instance of a script is already running

Larry Bates larry.bates at vitalEsafe.com
Sat Sep 13 17:07:04 CEST 2008


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 
> cross-platform.
> 
> 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.
> 
> Any idea ?
> 
> Best regards,
> Strato

Here is a recipe for Linux version of singleinstance class:

http://code.activestate.com/recipes/546512/

and I wrote and contributed the equivalent Windows version:

http://code.activestate.com/recipes/474070/

Hope this helps.

-Larry



More information about the Python-list mailing list