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)
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
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")