mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
[Enhancement]: Handle GH token refresh inside runtime (#6632)
This commit is contained in:
@@ -45,6 +45,7 @@ class RemoteRuntime(ActionExecutionClient):
|
||||
status_callback: Optional[Callable] = None,
|
||||
attach_to_existing: bool = False,
|
||||
headless_mode: bool = True,
|
||||
github_user_id: str | None = None,
|
||||
):
|
||||
super().__init__(
|
||||
config,
|
||||
@@ -55,6 +56,7 @@ class RemoteRuntime(ActionExecutionClient):
|
||||
status_callback,
|
||||
attach_to_existing,
|
||||
headless_mode,
|
||||
github_user_id,
|
||||
)
|
||||
if self.config.sandbox.api_key is None:
|
||||
raise ValueError(
|
||||
@@ -291,7 +293,8 @@ class RemoteRuntime(ActionExecutionClient):
|
||||
stop=tenacity.stop_after_delay(
|
||||
self.config.sandbox.remote_runtime_init_timeout
|
||||
)
|
||||
| stop_if_should_exit() | self._stop_if_closed,
|
||||
| stop_if_should_exit()
|
||||
| self._stop_if_closed,
|
||||
reraise=True,
|
||||
retry=tenacity.retry_if_exception_type(AgentRuntimeNotReadyError),
|
||||
wait=tenacity.wait_fixed(2),
|
||||
@@ -394,10 +397,14 @@ class RemoteRuntime(ActionExecutionClient):
|
||||
|
||||
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,
|
||||
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)
|
||||
return retry_decorator(self._send_action_server_request_impl)(
|
||||
method, url, **kwargs
|
||||
)
|
||||
|
||||
def _send_action_server_request_impl(self, method, url, **kwargs):
|
||||
try:
|
||||
@@ -430,6 +437,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