diff --git a/dank_mids/helpers/_session.py b/dank_mids/helpers/_session.py index 7234da31..5c3de08e 100644 --- a/dank_mids/helpers/_session.py +++ b/dank_mids/helpers/_session.py @@ -227,15 +227,16 @@ async def handle_too_many_requests(self, endpoint: str, error: ClientResponseErr if (now := time()) > getattr(limiter, "_last_updated_at", 0) + 10: current_rate = limiter._rate_per_sec new_rate = current_rate * 0.97 - limiter.time_period /= 0.97 - limiter._rate_per_sec = new_rate - limiter._last_updated_at = now - _logger_info( - "reduced requests per second for %s from %s to %s", - endpoint, - current_rate, - new_rate, - ) + if new_rate >= ENVS.MIN_REQUESTS_PER_SECOND: + limiter.time_period /= 0.97 + limiter._rate_per_sec = new_rate + limiter._last_updated_at = now + _logger_info( + "reduced requests per second for %s from %s to %s", + endpoint, + current_rate, + new_rate, + ) now = time() self._last_rate_limited_at = now