mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
Fix for issue where retries continue on a closed runtime (#6564)
Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user