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

This commit is contained in:
Xingyao Wang
2024-05-15 05:47:56 +08:00
committed by GitHub
parent 3cef8ee187
commit 123968f887

View File

@@ -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()