I have a situation where an application can launch a python script at any time. It can also launch the script multiple times almost simultaneously. I tried the following code in the script:
#prevent multiple instances locker=tmpdir+"/spamcop.lock" if (os.path.exists(locker)): exit lockfile=open(locker,"w"); lockfile.write("lock") lockfile.close()This does not seem to work. I suspect that the multiple scripts are launched so close that both fail the 'if' statement. Is there a better way, within the script itself, to prevent multiple copies running? TIA.