diff --git a/scripts/register/errors.py b/scripts/register/errors.py index faa2a2fea..42d5838a2 100755 --- a/scripts/register/errors.py +++ b/scripts/register/errors.py @@ -6,14 +6,12 @@ import sys import os import re import locking -from locking import trylock, unlock +from locking import lock, unlock From="accounts@vinyambar.de" # lock the input file: -if (trylock(sys.argv[1]+'.err')!=0): - print "Could not lock "+sys.argv[1]+".err" - sys.exit() +lock(sys.argv[1]+'.err',180) # move input file then unlock it: if os.access(sys.argv[1]+'.err', os.F_OK)==0: diff --git a/scripts/register/locking.py b/scripts/register/locking.py index e57a5fc6e..daf6c4124 100755 --- a/scripts/register/locking.py +++ b/scripts/register/locking.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import time import os import stat @@ -10,7 +11,7 @@ def trylock(file): return 1 return 0 -def lock(file): +def lock(file, timeout=60): locked=1 while locked: try: @@ -19,7 +20,7 @@ def lock(file): except: update=os.stat(file+'.lock')[stat.ST_MTIME] now=time.time() - if (now > update + 60): + if (now > update + timeout): locked=0 print "removing stale lockfile "+file+".lock" os.unlink(file+'.lock')