diff --git a/litellm/proxy/hooks/parallel_request_limiter_v3.py b/litellm/proxy/hooks/parallel_request_limiter_v3.py index 1933205f2cd..7331cbd5c34 100644 --- a/litellm/proxy/hooks/parallel_request_limiter_v3.py +++ b/litellm/proxy/hooks/parallel_request_limiter_v3.py @@ -1126,9 +1126,13 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): nx=True, parent_otel_span=parent_otel_span, ) - current_window_value = legacy_window_value if inserted else await redis_cache.async_get_cache( - key=window_key, - parent_otel_span=parent_otel_span, + current_window_value = ( + legacy_window_value + if inserted + else await redis_cache.async_get_cache( + key=window_key, + parent_otel_span=parent_otel_span, + ) ) if current_window_value is not None: await self.internal_usage_cache.async_set_cache( @@ -1212,9 +1216,7 @@ class _PROXY_MaxParallelRequestsHandler_v3(CustomLogger): # Only compute limit_remaining if current_limit is not None limit_remaining = ( - current_limit - int(effective_counter_value) - if effective_counter_value is not None - else current_limit + current_limit - int(effective_counter_value) if effective_counter_value is not None else current_limit ) statuses.append( diff --git a/tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py b/tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py index ad5707b6dd5..9955c6440f4 100644 --- a/tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py +++ b/tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py @@ -6359,10 +6359,10 @@ async def test_over_limit_mirror_does_not_reject_after_window_roll(monkeypatch, ) assert exc_info.value.status_code == 429 - # After the window boundary (t=59.75, while the stale mirror entry is - # still cached) the key must recover immediately instead of being + # After the window boundary (strictly past 60s, while the stale mirror + # entry is still cached) the key must recover immediately instead of being # rejected from the stale local mirror. - time_controller.advance(39.75) + time_controller.advance(40.25) await parallel_request_handler.async_pre_call_hook( user_api_key_dict=user_api_key_dict, cache=local_cache, data={}, call_type="" )