Skip to content

Commit a0c79f7

Browse files
happyherpopenhands-agenttofarr
authored
fix(Runtime): Wait for container to start up (#7548)
Co-authored-by: openhands <[email protected]> Co-authored-by: tofarr <[email protected]>
1 parent a44cdae commit a0c79f7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

openhands/runtime/impl/docker/docker_runtime.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
3737
APP_PORT_RANGE_2 = (55000, 59999)
3838

3939

40+
def _is_retryable_wait_until_alive_error(exception):
41+
if isinstance(exception, tenacity.RetryError):
42+
cause = exception.last_attempt.exception()
43+
return _is_retryable_wait_until_alive_error(cause)
44+
45+
return isinstance(
46+
exception, (ConnectionError, httpx.NetworkError, httpx.RemoteProtocolError)
47+
)
48+
49+
4050
class DockerRuntime(ActionExecutionClient):
4151
"""This runtime will subscribe the event stream.
4252
@@ -347,7 +357,7 @@ def _attach_to_container(self):
347357

348358
@tenacity.retry(
349359
stop=tenacity.stop_after_delay(120) | stop_if_should_exit(),
350-
retry=tenacity.retry_if_exception_type((ConnectionError, httpx.NetworkError)),
360+
retry=tenacity.retry_if_exception(_is_retryable_wait_until_alive_error),
351361
reraise=True,
352362
wait=tenacity.wait_fixed(2),
353363
)

0 commit comments

Comments
 (0)