Making sure script only runs once instance at a time.

Tim Williams tim at tdw.net
Fri Sep 29 11:57:15 EDT 2006


On 29/09/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> Tim Williams wrote:
>
> > def check_lock():
> >     import os, sys
> >     try:
> >         os.remove({filename})
> >     except:
> >         if "Permission denied" in sys.exc_info()[1]:
> >             print 'This program is already running'
> >             sys.exit()
> >     f_lock = open({filename},'w')
>
> have you actually tried this on a Unix system ?

Nope ,  I don't have one anywhere close.   I'm M$ only.

I did forget disclaimers like "try something like" and "not tested"
etc etc  - my bad  !!!

So that I know my mistake, which bit fails (the text from
sys.exc_info()[1]?? ) , or is it all complete rubbish - and not
do-able -  on a *nix system ?

:)



More information about the Python-list mailing list