471,119 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.

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

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".

Sep 12 '08 #1
0 1114

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Pierre-Yves | last post: by
8 posts views Thread by Paul Cochrane | last post: by
1 post views Thread by Kevin Otte | last post: by
4 posts views Thread by David | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.