__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
from collections import namedtuple
CubicParams = namedtuple('CubicParams', ['w_max', 'k', 'last_fail'])
class CubicCalculator:
_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):
scaled_value = (self._w_max * (1 - self._beta)) / self._scale_constant
k = scaled_value ** (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
)
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| __init__.py | File | 121 B | 0644 |
|
| adaptive.py | File | 4.11 KB | 0644 |
|
| base.py | File | 797 B | 0644 |
|
| bucket.py | File | 3.9 KB | 0644 |
|
| quota.py | File | 1.89 KB | 0644 |
|
| special.py | File | 1.62 KB | 0644 |
|
| standard.py | File | 19.51 KB | 0644 |
|
| throttling.py | File | 1.74 KB | 0644 |
|