mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-05 07:20:58 +00:00
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:
parent
b6c947442a
commit
9fd7b24344
1 changed files with 7 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue