Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Runtime only close then sandbox if it is created by itself (#1793)

Xingyao Wang123968f887a5
diff --git a/opendevin/runtime/runtime.py b/opendevin/runtime/runtime.py
index 36fb9e7833..3e2e47891b 100644
--- a/opendevin/runtime/runtime.py
+++ b/opendevin/runtime/runtime.py
@@ -64,15 +64,18 @@ class Runtime:
self.sid = sid
if sandbox is None:
self.sandbox = create_sandbox(sid, config.sandbox_type)
+ self._is_external_sandbox = False
else:
self.sandbox = sandbox
+ self._is_external_sandbox = True
self.browser = BrowserEnv()
self.event_stream = event_stream
self.event_stream.subscribe(EventStreamSubscriber.RUNTIME, self.on_event)
self._bg_task = asyncio.create_task(self._start_background_observation_loop())
def close(self):
- self.sandbox.close()
+ if not self._is_external_sandbox:
+ self.sandbox.close()
self.browser.close()
self._bg_task.cancel()