Private
Server IP : 195.201.23.43  /  Your IP : 18.117.92.75
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/botocore/retries/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/python3/dist-packages/botocore/retries/throttling.py
from collections import namedtuple

CubicParams = namedtuple('CubicParams', ['w_max', 'k', 'last_fail'])


class CubicCalculator(object):
    _SCALE_CONSTANT = 0.4
    _BETA = 0.7

    def __init__(self, starting_max_rate,
                 start_time,
                 scale_constant=_SCALE_CONSTANT, beta=_BETA):
        self._w_max = starting_max_rate
        self._scale_constant = scale_constant
        self._beta = beta
        self._k = self._calculate_zero_point()
        self._last_fail = start_time

    def _calculate_zero_point(self):
        k = ((self._w_max * (1 - self._beta)) / self._scale_constant) ** (1 / 3.0)
        return k

    def success_received(self, timestamp):
        dt = timestamp - self._last_fail
        new_rate = (
            self._scale_constant * (dt - self._k) ** 3 + self._w_max
        )
        return new_rate

    def error_received(self, current_rate, timestamp):
        # Consider not having this be the current measured rate.

        # We have a new max rate, which is the current rate we were sending
        # at when we received an error response.
        self._w_max = current_rate
        self._k = self._calculate_zero_point()
        self._last_fail = timestamp
        return current_rate * self._beta

    def get_params_snapshot(self):
        """Return a read-only object of the current cubic parameters.

        These parameters are intended to be used for debug/troubleshooting
        purposes.  These object is a read-only snapshot and cannot be used
        to modify the behavior of the CUBIC calculations.

        New parameters may be added to this object in the future.

        """
        return CubicParams(
            w_max=self._w_max,
            k=self._k,
            last_fail=self._last_fail
        )
Private