File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/retries.tar
Back
throttling.py 0000644 00000003363 15030215750 0007317 0 ustar 00 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 ) base.py 0000644 00000001435 15030215750 0006031 0 ustar 00 class BaseRetryBackoff: def delay_amount(self, context): """Calculate how long we should delay before retrying. :type context: RetryContext """ raise NotImplementedError("delay_amount") class BaseRetryableChecker: """Base class for determining if a retry should happen. This base class checks for specific retryable conditions. A single retryable checker doesn't necessarily indicate a retry will happen. It's up to the ``RetryPolicy`` to use its ``BaseRetryableCheckers`` to make the final decision on whether a retry should happen. """ def is_retryable(self, context): """Returns True if retryable, False if not. :type context: RetryContext """ raise NotImplementedError("is_retryable") __pycache__/throttling.cpython-310.pyc 0000644 00000003701 15030215750 0013652 0 ustar 00 o �h� � @ s, d dl mZ edg d��ZG dd� d�ZdS )� )� namedtuple�CubicParams��w_max�k� last_failc @ sB e Zd ZdZdZeefdd�Zdd� Zdd� Zd d � Zdd� Z d S )�CubicCalculatorg�������?gffffff�?c C s&