summaryrefslogtreecommitdiff
path: root/tct/resource_locking.py
diff options
context:
space:
mode:
authorAleksander Mistewicz <a.mistewicz@samsung.com>2016-07-12 18:17:03 +0200
committerAleksander Mistewicz <a.mistewicz@samsung.com>2016-10-07 17:13:09 +0200
commit1135c9c7824cc4c11b26eea2084f08e0bb2f75fe (patch)
tree705e61882791916c0bb36a5889c55c4e126dd780 /tct/resource_locking.py
parent6abbb99e95860e7ac7835ff1aee830c8f1d6a369 (diff)
downloadmajor-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-xtct/resource_locking.py19
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")