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
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):
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",
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!")