fix _time_to_sleep_before_retry

This commit is contained in:
Ishaan Jaff 2024-05-11 18:05:12 -07:00
parent c57ddf0537
commit 04bb2bf9f2

View file

@ -1512,11 +1512,11 @@ class Router:
Retry Logic Retry Logic
""" """
# raises an exception if this error should not be retries
_, _healthy_deployments = self._common_checks_available_deployment( _, _healthy_deployments = self._common_checks_available_deployment(
model=kwargs.get("model"), model=kwargs.get("model"),
) )
# raises an exception if this error should not be retries
self.should_retry_this_error( self.should_retry_this_error(
error=e, error=e,
healthy_deployments=_healthy_deployments, healthy_deployments=_healthy_deployments,
@ -1524,6 +1524,7 @@ class Router:
context_window_fallbacks=context_window_fallbacks, context_window_fallbacks=context_window_fallbacks,
) )
# decides how long to sleep before retry
_timeout = self._time_to_sleep_before_retry( _timeout = self._time_to_sleep_before_retry(
e=original_exception, e=original_exception,
remaining_retries=num_retries, remaining_retries=num_retries,
@ -1532,7 +1533,7 @@ class Router:
fallbacks=fallbacks, fallbacks=fallbacks,
) )
### RETRY # sleeps for the length of the timeout
await asyncio.sleep(_timeout) await asyncio.sleep(_timeout)
if ( if (
@ -1566,10 +1567,15 @@ class Router:
## LOGGING ## LOGGING
kwargs = self.log_retry(kwargs=kwargs, e=e) kwargs = self.log_retry(kwargs=kwargs, e=e)
remaining_retries = num_retries - current_attempt remaining_retries = num_retries - current_attempt
_, _healthy_deployments = self._common_checks_available_deployment(
model=kwargs.get("model"),
)
_timeout = self._time_to_sleep_before_retry( _timeout = self._time_to_sleep_before_retry(
e=original_exception, e=original_exception,
remaining_retries=remaining_retries, remaining_retries=remaining_retries,
num_retries=num_retries, num_retries=num_retries,
healthy_deployments=_healthy_deployments,
fallbacks=fallbacks,
) )
await asyncio.sleep(_timeout) await asyncio.sleep(_timeout)
try: try: