[Enhancement]: Handle GH token refresh inside runtime (#6632)

This commit is contained in:
Rohit Malhotra
2025-02-10 11:12:12 -05:00
committed by GitHub
parent 75f3f282af
commit 9bdc8dda6c
13 changed files with 66 additions and 25 deletions

View File

@@ -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