Set the ACK retry count for radio communication
511181
def set_arc(self, arc):
        
        _send_vendor_setup(self.handle, SET_RADIO_ARC, arc, 0, ())
        self.arc = arc
588592
def retry(self, delay=0, group=None, message=None):
        ''''''
        args = ['retry', self.jid, self.queue_name, self.worker_name, delay]
        if group is not None and message is not None:
            args.append(group)
            args.append(message)
        return self.client(*args)
905598
function CheckDevAckCB(err, results) {
        self.retry ++; // retry counter for ACK
        self.Debug (6, "CheckDevAckCB Phone=%s Retry=%d/%d Result=%j", smscmd.phone, self.retry, smsc.opts.retry, results);
        // ack no received
        if (results.length === 0) {
            if (self.retry <= smsc.opts.retry) {
                setTimeout (function() {CheckDevAck ();}, smsc.opts.delay);
            } else {
                self.Debug (7, "CheckDevAckCB Ack Abandoned MaxRetry=%s", smsc.opts.retry);
                appcb ({status: -2, smsid: smscmd.id});
            }
        } else {
            // we may have more than one responses for a given command
            for (var slot in results) {
                var ack =
                { status: 2
                    , smsid: smscmd.id
                    , phone: smscmd.phone
                    , ack: results[slot].TextDecoded
                };
                // ACK received, delete it from inbox and send it to application
                self.Debug (6, "CheckDevAckCB Ack Received %j", ack);
                smsc.DelById (DelByIdCB, results[slot].Id);
                appcb({status: 2, smsid: smscmd.id, msg: ack});
            }
            appcb({status: 0});
        }
    }
405443
def call_with_retry(func: Callable, exceptions, max_retries: int,
                    logger: Logger, *args, **kwargs):
    """"""
    attempt = 0
    while True:
        try:
            return func(*args, **kwargs)
        except exceptions as e:
            attempt += 1
            if attempt >= max_retries:
                raise

            delay = exponential_backoff(attempt, cap=60)
            logger.warning('%s: retrying in %s', e, delay)
            time.sleep(delay.total_seconds())
1071933
def retry(self, retries=3, backoff_factor=0.3, status_forcelist=(500, 502, 504)):
        
        retries = Retry(
            total=retries,
            read=retries,
            connect=retries,
            backoff_factor=backoff_factor,
            status_forcelist=status_forcelist,
        )
        # mount all https requests
        self.mount('https://', adapters.HTTPAdapter(max_retries=retries))
403637
function callback(err, response, body)
    {
      if (err)
      {
        // if we haven't exceeded the maximum number of retries yet and the
        // server came back with a retryable error code.
        if (numRetries < maxNumRetries && isRetryableError(response, err))
        {
          // increment the number of retries
          numRetries++;

          // use exponential backoff with decorrelated jitter to compute the
          // next sleep time:
          var cap = connectionConfig.getRetryLargeResultSetMaxSleepTime();
          sleep = Util.nextSleepTime(1, cap, sleep);

          // wait the appropriate amount of time before retrying the request
          setTimeout(sendRequest, sleep * 1000);
        }
        else
        {
          // wrap the error into a network error
          err = Errors.createNetworkError(
            ErrorCodes.ERR_LARGE_RESULT_SET_NETWORK_COULD_NOT_CONNECT, err);
        }
      }
      // if the response contains xml, build an S3/Blob error from the response
      else if (response.getResponseHeader('Content-Type') ===
        'application/xml')
      {
        err = Errors.createLargeResultSetError(
          ErrorCodes.ERR_LARGE_RESULT_SET_RESPONSE_FAILURE, response);
      }

      // if we have an error, clear the body
      if (err)
      {
        body = null;
      }

      // if a callback was specified, invoke it
      if (Util.isFunction(options.callback))
      {
        options.callback(err, body);
      }
    }
1069749
def auto_retry(fun):
    """"""

    @functools.wraps(fun)
    def decorated(instance, *args, **kwargs):
        """Wrapper around a decorated function."""
        cfg = instance._retry_config
        remaining_tries = cfg.retry_attempts
        current_wait = cfg.retry_wait
        retry_backoff = cfg.retry_backoff
        last_error = None

        while remaining_tries >= 0:
            try:
                return fun(instance, *args, **kwargs)
            except socket.error as e:
                last_error = e
                instance._retry_logger.warning('Connection failed: %s', e)

            remaining_tries -= 1
            if remaining_tries == 0:
                # Last attempt
                break

            # Wait a bit
            time.sleep(current_wait)
            current_wait *= retry_backoff

        # All attempts failed, let's raise the last error.
        raise last_error

    return decorated
356233
def set_ard_time(self, us):
        
        # Auto Retransmit Delay:
        # 0000 - Wait 250uS
        # 0001 - Wait 500uS
        # 0010 - Wait 750uS
        # ........
        # 1111 - Wait 4000uS

        # Round down, to value representing a multiple of 250uS
        t = int((us / 250) - 1)
        if (t < 0):
            t = 0
        if (t > 0xF):
            t = 0xF
        _send_vendor_setup(self.handle, SET_RADIO_ARD, t, 0, ())
1357462
public void trackFailure() {
        retryTime = Utils.currentTimeMillis() + (long)backoff;
        backoff = Math.min(backoff * params.multiplier, params.maximum);
    }
540736
private void ack() {
    // Send a message to the other side of the connection indicating the
    // last message that we received in order. This will allow it to
    // purge messages we've already received from its queue.
    if (open && connected) {
      if (log.isDebugEnabled()) {
        log.debug(String.format("%s - Acking messages up to: %d", this, lastReceived));
      }
      eventBus.send(outAddress, new JsonObject().putString("action", "ack").putNumber("id", lastReceived));
      lastFeedbackTime = System.currentTimeMillis();
    }
  }
191009
def ack(self, frame):
        
        if not frame.message_id:
            raise ProtocolError("No message-id specified for ACK command.")
        self.engine.queue_manager.ack(self.engine.connection, frame)
1027907
def _create_retry_request(self):
        """"""
        req_manager = _ReadRowsRequestManager(
            self.request, self.last_scanned_row_key, self._counter
        )
        return req_manager.build_updated_request()
134048
def handle(self, pkt, raddress, rport):
        ""
        if isinstance(pkt, TftpPacketACK):
            log.debug("Received ACK for packet %d" % pkt.blocknumber)
            # Is this an ack to the one we just sent?
            if self.context.next_block == pkt.blocknumber:
                if self.context.pending_complete:
                    log.info("Received ACK to final DAT, we're done.")
                    return None
                else:
                    log.debug("Good ACK, sending next DAT")
                    self.context.next_block += 1
                    log.debug("Incremented next_block to %d",
                        self.context.next_block)
                    self.context.pending_complete = self.sendDAT()

            elif pkt.blocknumber < self.context.next_block:
                log.warning("Received duplicate ACK for block %d"
                    % pkt.blocknumber)
                self.context.metrics.add_dup(pkt)

            else:
                log.warning("Oooh, time warp. Received ACK to packet we "
                         "didn't send yet. Discarding.")
                self.context.metrics.errors += 1
            return self
        elif isinstance(pkt, TftpPacketERR):
            log.error("Received ERR packet from peer: %s" % str(pkt))
            raise TftpException("Received ERR packet from peer: %s" % str(pkt))
        else:
            log.warning("Discarding unsupported packet: %s" % str(pkt))
            return self
1212121
def set_pin_retries(ctx, management_key, pin, pin_retries, puk_retries, force):
    
    controller = ctx.obj['controller']
    _ensure_authenticated(
        ctx, controller, pin, management_key, require_pin_and_key=True,
        no_prompt=force)
    click.echo('WARNING: This will reset the PIN and PUK to the factory '
               'defaults!')
    force or click.confirm('Set PIN and PUK retry counters to: {} {}?'.format(
        pin_retries, puk_retries), abort=True, err=True)
    try:
        controller.set_pin_retries(pin_retries, puk_retries)
        click.echo('Default PINs are set.')
        click.echo('PIN:    123456')
        click.echo('PUK:    12345678')
    except Exception as e:
        logger.error('Failed to set PIN retries', exc_info=e)
        ctx.fail('Setting pin retries failed.')
743677
def __send_ready_cb(self, last_send_failure_time):
        """"""
        logger.debug('Readiness notification (last failed=%s)', last_send_failure_time)
        # It is possible for multiple timers to be scheduled (if multiple transport failures happen in a fairly short
        # amount of time. See logic for __send_retry_requests
        if last_send_failure_time is not None:
            self.__send_retry_requests_timer.cancel()
            # allow 10s for responses to come in before attempting to resend
            self.__send_retry_requests_timer = Timer(10, self.__send_retry_requests, args=(last_send_failure_time,))
            self.__send_retry_requests_timer.start()
1092533
static synchronized void setRetryBroadcastReceiver(Context context) {
        if (sRetryReceiver == null) {
            if (sRetryReceiverClassName == null) {
                // should never happen
                Log.e(TAG, "internal error: retry receiver class not set yet");
                sRetryReceiver = new GCMBroadcastReceiver();
            } else {
                Class<?> clazz;
                try {
                    clazz = Class.forName(sRetryReceiverClassName);
                    sRetryReceiver = (GCMBroadcastReceiver) clazz.newInstance();
                } catch (Exception e) {
                    Log.e(TAG, "Could not create instance of " +
                            sRetryReceiverClassName + ". Using " +
                            GCMBroadcastReceiver.class.getName() +
                            " directly.");
                    sRetryReceiver = new GCMBroadcastReceiver();
                }
            }
            String category = context.getPackageName();
            IntentFilter filter = new IntentFilter(
                    GCMConstants.INTENT_FROM_GCM_LIBRARY_RETRY);
            filter.addCategory(category);
            // must use a permission that is defined on manifest for sure
            String permission = category + ".permission.C2D_MESSAGE";
            Log.v(TAG, "Registering receiver");
            context.registerReceiver(sRetryReceiver, filter, permission, null);
        }
    }
1169321
def recv(self, stream, crc_mode=1, retry=16, timeout=60, delay=1, quiet=0):
        '''
        
        '''

        # initiate protocol
        error_count = 0
        char = 0
        cancel = 0
        while True:
            # first try CRC mode, if this fails,
            # fall back to checksum mode
            if error_count >= retry:
                self.abort(timeout=timeout)
                return None
            elif crc_mode and error_count < (retry / 2):
                if not self.putc(CRC):
                    time.sleep(delay)
                    error_count += 1
            else:
                crc_mode = 0
                if not self.putc(NAK):
                    time.sleep(delay)
                    error_count += 1

            char = self.getc(1, timeout)
            if not char:
                error_count += 1
                continue
            elif char == SOH:
                #crc_mode = 0
                break
            elif char == STX:
                break
            elif char == CAN:
                if cancel:
                    return None
                else:
                    cancel = 1
            else:
                error_count += 1

        # read data
        error_count = 0
        income_size = 0
        packet_size = 128
        sequence = 1
        cancel = 0
        while True:
            while True:
                if char == SOH:
                    packet_size = 128
                    break
                elif char == STX:
                    packet_size = 1024
                    break
                elif char == EOT:
                    # We received an EOT, so send an ACK and return the received
                    # data length
                    self.putc(ACK)
                    return income_size
                elif char == CAN:
                    # cancel at two consecutive cancels
                    if cancel:
                        return None
                    else:
                        cancel = 1
                else:
                    if not quiet:
                        print >> sys.stderr, \
                            'recv ERROR expected SOH/EOT, got', ord(char)
                    error_count += 1
                    if error_count >= retry:
                        self.abort()
                        return None
            # read sequence
            error_count = 0
            cancel = 0
            seq1 = ord(self.getc(1))
            seq2 = 0xff - ord(self.getc(1))
            if seq1 == sequence and seq2 == sequence:
                # sequence is ok, read packet
                # packet_size + checksum
                data = self.getc(packet_size + 1 + crc_mode, timeout)
                if crc_mode:
                    csum = (ord(data[-2]) << 8) + ord(data[-1])
                    data = data[:-2]
                    log.debug('CRC (%04x <> %04x)' % \
                        (csum, self.calc_crc(data)))
                    valid = csum == self.calc_crc(data)
                else:
                    csum = data[-1]
                    data = data[:-1]
                    log.debug('checksum (checksum(%02x <> %02x)' % \
                        (ord(csum), self.calc_checksum(data)))
                    valid = ord(csum) == self.calc_checksum(data)

                # valid data, append chunk
                if valid:
                    income_size += len(data)
                    stream.write(data)
                    self.putc(ACK)
                    sequence = (sequence + 1) % 0x100
                    char = self.getc(1, timeout)
                    continue
            else:
                # consume data
                self.getc(packet_size + 1 + crc_mode)
                self.debug('expecting sequence %d, got %d/%d' % \
                    (sequence, seq1, seq2))

            # something went wrong, request retransmission
            self.putc(NAK)