Execute the requests of all given Curl instances

@param Curl[] $instances An array of Curl instances (key = name of instance)
@param int $retryCount The maximum number of retries
@param int $retryWait Time in seconds to wait between each try
770852
private function subExec($instances, $retryCount = 0, $retryWait = 0)
    {
        $curlMultiInstance = curl_multi_init();

        foreach ($instances as $name => $curlInstance) {
            curl_multi_add_handle($curlMultiInstance, $curlInstance->getHandle());
        }

        do {
            curl_multi_exec($curlMultiInstance, $stillRunning);
            curl_multi_select($curlMultiInstance);
        } while ($stillRunning);

        for ($retry = 1; $retry <= $retryCount; $retry++) {
            $retryRequired = false;

            foreach ($instances as $curlInstance) {
                if (!$curlInstance->isSuccessful()) {
                    $retryRequired = true;
                    break;
                }
            }

            if (!$retryRequired) {
                break;
            }

            sleep($retryWait);

            $this->retryFailed($instances);
        }

        foreach ($instances as $curlInstance) {
            $curlInstance->setContent(curl_multi_getcontent($curlInstance->getHandle()));
        }

        curl_multi_close($curlMultiInstance);
    }
400931
public function invoke($queueName, $payload, $resultType, $timeout = 10)
    {
        $rs = $this->invokeAll(array(array($queueName, $payload, $resultType)), $timeout);
        if ($rs[0] instanceof RpcError) {
            throw new RpcErrorException($rs[0]);
        }

        return $rs[0];
    }
167843
private void doWait( int currentTries, long optDuration_ms )
    {
        if ( optDuration_ms < 0 ) {
            optDuration_ms = ( long ) ( firstSleep_ms * ( Math.random() + 0.5 ) * ( 1L << ( currentTries - 1 ) ) );
        }

        LOGGER.debug( "Will retry request after {} millis", optDuration_ms );

        try {
            Thread.sleep( optDuration_ms );
        } catch ( InterruptedException ex ) {
            throw new CStorageException( "Retry waiting interrupted", ex );
        }
    }
1260862
private void scheduleForRetry(final CouchbaseRequest request, final boolean isNotMyVbucket) {
        CoreEnvironment env = environment;
        long delayTime;
        TimeUnit delayUnit;

        if (request.retryDelay() != null) {
            Delay delay = request.retryDelay();
            if (request.retryCount() == 0) {
                delayTime = request.retryAfter();
                request.incrementRetryCount();
            } else {
                delayTime = delay.calculate(request.incrementRetryCount());
            }
            delayUnit = delay.unit();
            if (request.maxRetryDuration() != 0 && ((System.currentTimeMillis()) + delayTime) > request.maxRetryDuration()) {
                request.observable().onError(new RequestCancelledException("Could not dispatch request, cancelling "
                        + "instead of retrying as the maximum retry duration specified by Server has been exceeded"));
                return;
            }
        } else {
            Delay delay = env.retryDelay();
            if (isNotMyVbucket) {
                boolean hasFastForward = bucketHasFastForwardMap(request.bucket(), configurationProvider.config());
                delayTime = request.incrementRetryCount() == 0 && hasFastForward ? 0 : nmvbRetryDelay;
                delayUnit = TimeUnit.MILLISECONDS;
            } else {
                delayTime = delay.calculate(request.incrementRetryCount());
                delayUnit = delay.unit();
            }
        }

        if (traceLoggingEnabled) {
            LOGGER.trace("Retrying {} with a delay of {} {}", request, delayTime, delayUnit);
        }

        final Scheduler.Worker worker = env.scheduler().createWorker();
        worker.schedule(new Action0() {
            @Override
            public void call() {
                try {
                    cluster.send(request);
                } finally {
                    worker.unsubscribe();
                }
            }
        }, delayTime, delayUnit);
    }
1080512
public static function execute($ch, $retries = 3, $closeAfterDone = true)
    {
        $ret = '';
        while ($retries--) {
            if (($ret = curl_exec($ch)) === false) {
                $curlErrNo = curl_errno($ch);

                if (false === \in_array($curlErrNo, self::$canRetryErrorCodes, true) || !$retries) {
                    $curlError = curl_error($ch);

                    if ($closeAfterDone) {
                        curl_close($ch);
                    }

                    throw new \RuntimeException(sprintf('Curl error (code %s): %s', $curlErrNo, $curlError));
                }

                continue;
            }

            if ($closeAfterDone) {
                curl_close($ch);
            }
            break;
        }

        return $ret;
    }
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))
882627
public function priority($priority, $retryTimeout = null, $expireAfter = null)
    {
        $this->noEmergencyWithoutRetryOrExpire($priority, $retryTimeout, $expireAfter);

        $this->priority = $priority;
        $this->retry = $retryTimeout;
        $this->expire = $expireAfter;

        return $this;
    }
533334
def retry(max_retries=1):
    

    def retry_func(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            num_retries = 0
            while num_retries <= max_retries:
                try:
                    ret = func(*args, **kwargs)
                    break
                except HTTPError:
                    if num_retries == max_retries:
                        raise
                    num_retries += 1
                    time.sleep(5)
            return ret

        return wrapper

    return retry_func
969881
def repeat_call(func, retries, *args, **kwargs):
    '''
    
    '''
    retries = max(0, int(retries))
    try_num = 0
    while True:
        if try_num == retries:
            return func(*args, **kwargs)
        else:
            try:
                return func(*args, **kwargs)
            except Exception as e:
                if isinstance(e, KeyboardInterrupt):
                    raise e
                try_num += 1
1345226
def retry(self, func, partition_id, retry_message, final_failure_message, max_retries, host_id):
        
        loop = asyncio.new_event_loop()
        loop.run_until_complete(self.retry_async(func, partition_id, retry_message,
                                                 final_failure_message, max_retries, host_id))
142455
public static function retry(&$api, $config)
    {
        $retryRequest = function (
            $retries, $request, $response, $error
        ) use ($api, $config) {
            // Refresh token middleware
            if ($response and $response->getStatusCode() == 401) {
                return self::refreshToken($api, $config, $retries);
            }

            // Don't retry on other requests.
            return false;
        };

        return Middleware::retry($retryRequest);
    }
1325921
def retry(retries=10, wait=5, catch=None):
    
    catch = catch or (Exception,)

    def real_retry(function):

        def wrapper(*args, **kwargs):
            for _ in range(retries):
                try:
                    ret = function(*args, **kwargs)
                    return ret
                except catch:
                    time.sleep(wait)
                except Exception as e:
                    raise e
                else:
                    raise DSBException('Retries limit exceded.')

        return wrapper

    return real_retry
1275527
@Override
    public void retry(VolleyError error) throws VolleyError {
        mCurrentRetryCount++;
        mCurrentTimeoutMs += (mCurrentTimeoutMs * mBackoffMultiplier);
        if (!hasAttemptRemaining()) {
            throw error;
        }
    }
974154
private function _executeCurl($url, $requestMethod, $key, $params = null)
    {
        $ch = curl_init($url);

        curl_setopt_array($ch, $this->genOptions($requestMethod, $key.':', $params));

        // Make a request or thrown an exception.
        if (($result = curl_exec($ch)) === false) {
            $error = curl_error($ch);
            curl_close($ch);

            throw new Exception($error);
        }

        // Close.
        curl_close($ch);

        return $result;
    }
957195
function Retry(conf) {
  component.Component.call(this, 'controller', conf);
  this.registerGearman(conf.servers, {
    client: true,
    worker: {
      func_name: 'retryController',
      func: _.bind( function(json_string, worker) {
        try {
          // TODO: this parsing and meta parameter storing should be encapsulated into a Task class
          var task = JSON.parse( json_string.toString() );
          task._task_json_string = json_string;
          task._task_worker = worker;

          this.execute_task( task );
        }
        catch ( e ) {
          _err( 'Error executing retryController with following payload:', json_string );
        }
      }, this )
    }
  });
}
1160132
public static function lockWait($key, $reTryTimes = 3)
    {
        $reTryTimes = intval($reTryTimes);

        $i = 0;
        while (!self::lock($key)) {
            if (++$i >= $reTryTimes) {
                return false;
            }
            usleep(2000);
        }

        return true;
    }
166387
public function retry($wait, $curlHandle)
    {
        sleep($wait);
        $result = curl_exec($curlHandle);
        $this->_lastStatusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
        return $result;
    }