Fix for issue where retries continue on a closed runtime (#6564)

Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
This commit is contained in:
tofarr
2025-02-03 08:44:09 -07:00
committed by GitHub
parent 622fc5213d
commit bbfdc62139
24 changed files with 38 additions and 7 deletions

View File

@@ -291,7 +291,7 @@ class RemoteRuntime(ActionExecutionClient):
stop=tenacity.stop_after_delay(
self.config.sandbox.remote_runtime_init_timeout
)
| stop_if_should_exit(),
| stop_if_should_exit() | self._stop_if_closed,
reraise=True,
retry=tenacity.retry_if_exception_type(AgentRuntimeNotReadyError),
wait=tenacity.wait_fixed(2),
@@ -388,12 +388,18 @@ class RemoteRuntime(ActionExecutionClient):
)
raise
@tenacity.retry(
retry=tenacity.retry_if_exception_type(ConnectionError),
stop=tenacity.stop_after_attempt(3) | stop_if_should_exit(),
wait=tenacity.wait_exponential(multiplier=1, min=4, max=60),
)
def _send_action_server_request(self, method, url, **kwargs):
if not self.config.sandbox.remote_runtime_enable_retries:
return self._send_action_server_request(method, url, **kwargs)
retry_decorator = tenacity.retry(
retry=tenacity.retry_if_exception_type(ConnectionError),
stop=tenacity.stop_after_attempt(3) | stop_if_should_exit() | self._stop_if_closed,
wait=tenacity.wait_exponential(multiplier=1, min=4, max=60),
)
return retry_decorator(self._send_action_server_request_impl)(method, url, **kwargs)
def _send_action_server_request_impl(self, method, url, **kwargs):
try:
return super()._send_action_server_request(method, url, **kwargs)
except requests.Timeout:
@@ -424,3 +430,6 @@ class RemoteRuntime(ActionExecutionClient):
) from e
else:
raise e
def _stop_if_closed(self, retry_state: tenacity.RetryCallState) -> bool:
return self._runtime_closed