diff options
author | Aleksander Mistewicz <a.mistewicz@samsung.com> | 2016-07-12 18:17:03 +0200 |
---|---|---|
committer | Aleksander Mistewicz <a.mistewicz@samsung.com> | 2016-10-07 17:13:09 +0200 |
commit | 1135c9c7824cc4c11b26eea2084f08e0bb2f75fe (patch) | |
tree | 705e61882791916c0bb36a5889c55c4e126dd780 /tct/resource_locking.py | |
parent | 6abbb99e95860e7ac7835ff1aee830c8f1d6a369 (diff) | |
download | major-1135c9c7824cc4c11b26eea2084f08e0bb2f75fe.tar.gz major-1135c9c7824cc4c11b26eea2084f08e0bb2f75fe.tar.bz2 major-1135c9c7824cc4c11b26eea2084f08e0bb2f75fe.zip |
Check for UUID files in tct/resource_locking.py
Change-Id: Ib593cf3958392807d05d6c07cecb27c93024f581
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Diffstat (limited to 'tct/resource_locking.py')
-rwxr-xr-x | tct/resource_locking.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tct/resource_locking.py b/tct/resource_locking.py index af25f7d..bb0b44b 100755 --- a/tct/resource_locking.py +++ b/tct/resource_locking.py @@ -129,6 +129,15 @@ class UUIDmanager: logging.info("Failed to lock") return False + def target_list_is_empty(self): + # return True if there are no files available for target (including locked) + # False otherwise + target_list = UUIDlist.target(self.target) + if len(target_list) == 0: + logging.error("Target list for \"%s\" is empty", self.target) + return True + return False + def unlock(self): # remove lock on specified target # returns True if operation was successful (no lock is present) @@ -137,9 +146,14 @@ class UUIDmanager: return Lockfile.unlock(UUID_DIR + UUID_PREFIX + self.target) == 0 def retrylock(self): - # try to lock a target every 60s. finish if operation is successful + # try to lock a target every 60s + # returns False if there are no available targets + # True otherwise while not self.lock(): + if self.target_list_is_empty(): + return False time.sleep(60) + return True def unlockfailed(self): # unlock target as usual and increase its counter by 10 @@ -196,7 +210,8 @@ def main(): if not uuid_man.unlock(): logging.warn("File unlocking unsuccessful!") elif args.retrylock: - uuid_man.retrylock() + if not uuid_man.retrylock(): + logging.warn("Retrylock unsuccessful!") elif args.unlockfailed: uuid_man.unlockfailed() logging.debug("End") |