fix(Runtime): Wait for container to start up (#7548)

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: tofarr <tofarr@gmail.com>
This commit is contained in:
Carlos Freund 2025-03-27 20:55:06 +01:00 committed by GitHub
parent a44cdae36e
commit a0c79f7388
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,6 +37,16 @@ APP_PORT_RANGE_1 = (50000, 54999)
APP_PORT_RANGE_2 = (55000, 59999)
def _is_retryable_wait_until_alive_error(exception):
if isinstance(exception, tenacity.RetryError):
cause = exception.last_attempt.exception()
return _is_retryable_wait_until_alive_error(cause)
return isinstance(
exception, (ConnectionError, httpx.NetworkError, httpx.RemoteProtocolError)
)
class DockerRuntime(ActionExecutionClient):
"""This runtime will subscribe the event stream.
@ -347,7 +357,7 @@ class DockerRuntime(ActionExecutionClient):
@tenacity.retry(
stop=tenacity.stop_after_delay(120) | stop_if_should_exit(),
retry=tenacity.retry_if_exception_type((ConnectionError, httpx.NetworkError)),
retry=tenacity.retry_if_exception(_is_retryable_wait_until_alive_error),
reraise=True,
wait=tenacity.wait_fixed(2),
)