mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
Runtime only close then sandbox if it is created by itself (#1793)
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user