forked from github/server
Diverse Bugfixes
This commit is contained in:
parent
24f3cbd6ae
commit
538bed3c70
|
@ -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:
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue