check instace already running...
Sidharth Kuruvila
sidharth.kuruvila at gmail.com
Sat Apr 9 05:21:45 EDT 2005
I haven't tested this. There is probably a better way of doing this
looking at process information. I use a lock file to mark that the
program is already running. The problem is that for an abrupt shutdown
the file might not be removed.
import atexit
if os.path.exists(lockfile):
print "there is an instance already running"
else:
file(lockfile, "w").close()
atexit.register(lambda:os.remove(lockfile))
//Your code here
On Apr 9, 2005 2:32 PM, Sidharth Kuruvila <sidharth.kuruvila at gmail.com> wrote:
> I haven't tested this. There is probably a better way of doing this
> looking at process information. I use a lock file to mark that the
> program is already running. The problem is that for an abrupt shutdown
> the file might not be removed.
>
> import atexit
> if os.path.exists(lockfile):
> print "there is an instance already running"
> else:
> file(lockfile, "w").close()
> atexit.register(lambda:os.remove(lockfile))
>
> //Your code here
>
> On Apr 9, 2005 2:01 PM, Fabio Pliger <fabio.pliger at siavr.it> wrote:
> > Hi,
> > is it possibile, in python, to check for an already running instance of an
> > application?
> > My problem is that, if my program i running and the user relaunch it, i
> > don't want to open a new instance and have to instances of the same program
> > running togheter...
> > Can someone help me on this?
> > Fabio P.
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
> --
> http://blogs.applibase.net/sidharth
>
--
http://blogs.applibase.net/sidharth
More information about the Python-list
mailing list