Making sure script only runs once instance at a time.

Fredrik Lundh fredrik at pythonware.com
Fri Sep 29 11:32:33 EDT 2006


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 ?

</F>




More information about the Python-list mailing list