'Main loop for Threading.
This function is the main loop of the thread. It checks the jail
queue and executes commands when an IP address is banned.
Returns
bool
True when the thread exits nicely.'

def run(self):

    for (name, action) in self._actions.iteritems():
        try:
            action.start()
        except Exception as e:
            logSys.error("Failed    to    start    jail    '%s'    action    '%s':    %s", self._jail.name, name, e, exc_info=(logSys.getEffectiveLevel() <= logging.DEBUG))
    while self.active:
        if self.idle:
            Utils.wait_for((lambda : ((not self.active) or (not self.idle))), (self.sleeptime * 10), self.sleeptime)
            continue
        if (not Utils.wait_for((lambda : ((not self.active) or self.__checkBan())), self.sleeptime)):
            self.__checkUnBan()
    self.__flushBan()
    self.stopActions()
    return True
