check return value of acquire()

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3034 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2006-02-01 19:48:22 +00:00
parent b6c947442a
commit 9fd7b24344

View file

@ -103,7 +103,13 @@ def _synchronized (lock, func):
"""
Execute function synchronized.
"""
lock.acquire(True) # blocking
# acquire lock waiting indefinitely, with a maximum number of tries
tries = 1
while not lock.acquire():
time.sleep(0.5)
tries += 1
if tries > 5:
raise RuntimeError("Could not acquire lock")
try:
return func(*args, **kwargs)
finally: