From 9fd7b24344a2bd187eee8280cc54eaef332c24b0 Mon Sep 17 00:00:00 2001 From: calvin Date: Wed, 1 Feb 2006 19:48:22 +0000 Subject: [PATCH] check return value of acquire() git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3034 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkcheck/decorators.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/linkcheck/decorators.py b/linkcheck/decorators.py index b0402da6..6dc4da5a 100644 --- a/linkcheck/decorators.py +++ b/linkcheck/decorators.py @@ -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: