Skip to content

πŸ™Œ OpenHands: AI-Driven Development

ssh_box: Shutdown container when fail to start ssh session (#1872)

Boxuan Li0abc35cf5762
diff --git a/opendevin/runtime/docker/ssh_box.py b/opendevin/runtime/docker/ssh_box.py
index 9d7e0cc3dc..dd50c38ad3 100644
--- a/opendevin/runtime/docker/ssh_box.py
+++ b/opendevin/runtime/docker/ssh_box.py
@@ -253,7 +253,13 @@ class DockerSSHBox(Sandbox):
raise e
time.sleep(5)
self.setup_user()
- self.start_ssh_session()
+
+ try:
+ self.start_ssh_session()
+ except pxssh.ExceptionPxssh as e:
+ self.close()
+ raise e
+
# make sure /tmp always exists
self.execute('mkdir -p /tmp')
# set git config