diff options
author | Aleksander Mistewicz <a.mistewicz@samsung.com> | 2016-10-07 17:26:24 +0200 |
---|---|---|
committer | Aleksander Mistewicz <a.mistewicz@samsung.com> | 2016-10-07 17:29:30 +0200 |
commit | 3914aa52b42d20f7ee83d742c58d5a398155cd5e (patch) | |
tree | d37019341f7cee0a157d2ce206a158c3ccf92ecd /tct | |
parent | 1c0e9c8388db48222b6f2c1f6dcac451e98c2b38 (diff) | |
download | major-3914aa52b42d20f7ee83d742c58d5a398155cd5e.tar.gz major-3914aa52b42d20f7ee83d742c58d5a398155cd5e.tar.bz2 major-3914aa52b42d20f7ee83d742c58d5a398155cd5e.zip |
Remove magic HOLDOFF number in resource_locking.py
Change-Id: I56cf4cadb695bc12b5494f4fab404ab8905af733
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Diffstat (limited to 'tct')
-rwxr-xr-x | tct/resource_locking.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tct/resource_locking.py b/tct/resource_locking.py index 5183411..7c94e30 100755 --- a/tct/resource_locking.py +++ b/tct/resource_locking.py @@ -111,9 +111,10 @@ class UUIDlist(object): return ret class UUIDmanager: - def __init__(self, target, inc): + def __init__(self, target, inc, holdoff): self.target = target self.inc = inc + self.holdoff = holdoff def lock(self): # go through the list of not locked uuid files and stop on the first successfully locked @@ -147,13 +148,13 @@ class UUIDmanager: return Lockfile.unlock(UUID_DIR + UUID_PREFIX + self.target) == 0 def retrylock(self): - # try to lock a target every 60s + # try to lock a target every self.holdoff seconds # 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) + time.sleep(self.holdoff) return True def unlockfailed(self): @@ -177,7 +178,11 @@ def parse_arguments(): group.add_argument("-r", "--retrylock", action="store_true", default=False, dest="retrylock", - help="Try to lock a device until successful") + help="Try to lock a device every HOLDOFF seconds until successful") + + parser.add_argument("--holdoff", type=int, + action="store", default=60, dest="holdoff", + help="Set HOLDOFF value (default: 60)") group.add_argument("-u", "--unlock", action="store_true", default=False, dest="unlock", @@ -207,7 +212,7 @@ def main(): raise ValueError('Invalid log level: %s' % args.loglevel) logging.basicConfig(format='%(asctime)s %(message)s',level=numeric_level) logging.debug("Begin") - uuid_man = UUIDmanager(args.target, args.inc) + uuid_man = UUIDmanager(args.target, args.inc, args.holdoff) if args.lock: if not uuid_man.lock(): logging.warn("File locking unsuccessful!") |