Make sure that all failures happen in the same amount of time
515281
def time_auth(self, load):
        '''
        
        '''
        start = time.time()
        ret = self.__auth_call(load)
        if ret:
            return ret
        f_time = time.time() - start
        if f_time > self.max_fail:
            self.max_fail = f_time
        deviation = self.max_fail / 4
        r_time = random.SystemRandom().uniform(
                self.max_fail - deviation,
                self.max_fail + deviation
                )
        while start + r_time > time.time():
            time.sleep(0.001)
        return False
940316
def num_fails(self):
        """"""
        n = len(self.failed_phase_list)
        if self.phase_stack[-1].status in (SolverStatus.failed, SolverStatus.cyclic):
            n += 1
        return n
1236211
function failFast(logLevel, lessThan) {
    var ll = LatticeLogs;

    if (logLevel) {
      var compareTo = lessThan || process.env.LATTICE_LOGLEVEL || ll.ERROR;
      if (!ll.equalOrBelow(logLevel, compareTo)) return true;
    }

    return /\b(NONE|OFF|NO|0)\b/i.test(process.env.LATTICE_ERRORS || '');
  }
382126
def every(secs):
    '''
    
    '''
    time_stated = time.monotonic()
    while True:
        time_yielded = time.monotonic()
        yield time_yielded - time_stated
        time.sleep(max(0, secs + time_yielded - time.monotonic()))
669940
def ready(self):
        ''''''
        if self._last_failed:
            delta = time.time() - self._last_failed
            return delta >= self.backoff()
        return True
614179
def _fail(self, message, text, i):
        """"""

        raise ValueError("{}:\n{}".format(message, text[i : i + 79]))
109011
def add_failure(self):
        
        failure_time = time.time()

        if not self.first_failure_time:
            self.first_failure_time = failure_time

        self.failures.append(failure_time)
216883
def on_failure(&block)
      on do |_, _, reason|
        block.call(reason) if reason
      end
    end
1201872
def failure_count(self):
        
        return len([i for i, result in enumerate(self.data) if result.failure])
972517
def maintainConnections(self, force=False):
        
        now = time.perf_counter()
        if now < self.nextCheck and not force:
            return False
        self.nextCheck = now + (self.config.RETRY_TIMEOUT_NOT_RESTRICTED
                                if self.isKeySharing
                                else self.config.RETRY_TIMEOUT_RESTRICTED)
        missing = self.connectToMissing()
        self.retryDisconnected(exclude=missing)
        logger.trace("{} next check for retries in {:.2f} seconds"
                     .format(self, self.nextCheck - now))
        return True
1191037
def check_if_ready(self):
        """"""
        try:
            results = self.manager.check(self.results_id)
        except exceptions.ResultsNotReady as e:
            self._is_ready = False
            self._not_ready_exception = e
        except exceptions.ResultsExpired as e:
            self._is_ready = True
            self._expired_exception = e
        else:
            failures = self.get_failed_requests(results)
            members = self.get_new_members(results)
            self.results = self.__class__.Results(list(members), list(failures))
            self._is_ready = True
            self._not_ready_exception = None
1067567
def on_failure(self, exc, task_id, args, kwargs, einfo):
        
        log.error('[{}] failed due to {}'.format(task_id, getattr(einfo, 'traceback', None)))
        super(LoggedTask, self).on_failure(exc, task_id, args, kwargs, einfo)
318292
def _retry(n, f, *args, **kwargs):
    ''''''

    for i in range(n):
        try:
            return f(*args, **kwargs)
        except Exception as exc:
            if i == n - 1:
                log.error(
                    '%s permanently failed with %r', f.__name__, exc)
                raise
            else:
                log.warning(
                    '%s attempt #%d failed with %r', f.__name__, i, exc)
                time.sleep(2 ** i)
    raise RuntimeError('Should never get here!')
843253
def temp_fail_retry(error, fun, *args):
    """"""
    while 1:
        try:
            return fun(*args)
        except error as e:
            eintr = errno.WSAEINTR if os.name == 'nt' else errno.EINTR
            if e.args[0] == eintr:
                continue
            raise
738911
def n_failed(self):
        """"""
        return self._counters[JobStatus.failed] + self._counters[JobStatus.partial_failed]
320470
def issue(self, test, err):
        """"""
        self.step.setProgress('tests failed', len(self.failures) +
                              len(self.errors))
1357462
public void trackFailure() {
        retryTime = Utils.currentTimeMillis() + (long)backoff;
        backoff = Math.min(backoff * params.multiplier, params.maximum);
    }