IPC via files, sockets, and shared memory are all readily available in
python.
the simplest way is to have the script write its pid to a certain file.

pidfn = '/tmp/hellowerld_ipc_pid'
if os.path.isfile(pidfn):
    f = file(pidfn)
    pid = f.read()
    f.close()
    if pid in os.popen('ps -A -o pid').read():
        print "another instance of me is running!"
    else:
        f = file(pidfn, 'w')
        f.write(str(os.getpid()))
        f.close()


gmax2006 wrote:
> Hi,
>
> Is it possible that a python script finds out whether another instance
> of it is currently running or not?
> 
> Thank you,
> Max

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to