From b131650974fd39d51c97f68a42b998f1c0fa7d0e Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 4 Oct 2011 20:44:16 +0200 Subject: [PATCH] [entropy.tools] acquire_entropy_locks, acquire_entropy_resources_lock: add keyword arg max_tries --- libraries/entropy/tools.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libraries/entropy/tools.py b/libraries/entropy/tools.py index 357ae0bc9..2bfcd5610 100644 --- a/libraries/entropy/tools.py +++ b/libraries/entropy/tools.py @@ -3027,7 +3027,8 @@ def release_lock(lock_file, lock_map): if err.errno != errno.ENOENT: raise -def acquire_entropy_locks(entropy_client, blocking = False): +def acquire_entropy_locks(entropy_client, blocking = False, + max_tries = 300): """ Acquire Entropy Client/Server file locks. @@ -3035,14 +3036,17 @@ def acquire_entropy_locks(entropy_client, blocking = False): @type entropy_client: entropy.client.interfaces.Client @keyword blocking: acquire locks in blocking mode? @type blocking: bool + @keyword max_tries: number of tries for wait_resources() + @type max_tries: int """ locked = entropy_client.another_entropy_running() if locked: return False return acquire_entropy_resources_locks(entropy_client, - blocking = blocking) + blocking = blocking, max_tries = max_tries) -def acquire_entropy_resources_locks(entropy_client, blocking = False): +def acquire_entropy_resources_locks(entropy_client, blocking = False, + max_tries = 300): """ Acquire Entropy Resources General Lock. This lock is controlling write access to entropy package metadata and @@ -3053,9 +3057,11 @@ def acquire_entropy_resources_locks(entropy_client, blocking = False): @type entropy_client: entropy.client.interfaces.Client @keyword blocking: acquire locks in blocking mode? @type blocking: bool + @keyword max_tries: number of tries for wait_resources() + @type max_tries: int """ if not blocking: - gave_up = entropy_client.wait_resources() + gave_up = entropy_client.wait_resources(max_lock_count = max_tries) if gave_up: return False