Re: testing if another instance of a script is already running

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Golden

    #1

    Re: testing if another instance of a script is already running

    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
    >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.
    >
    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):
    >
    http://mail.python.org/pipermail/pyt...ne/327063.html
    Sorry, not the best of links to point to. Basically, search
    mail.python.org for things like "CreateMute x" and
    "single application instance".

    TJG
Working...