From c5491e87aa8d2c5ea33d7c0a982386b5b90aa32d Mon Sep 17 00:00:00 2001 From: tofarr Date: Wed, 26 Mar 2025 12:12:59 -0600 Subject: [PATCH] Run runtime.close in background thread (#7524) --- openhands/server/session/agent_session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openhands/server/session/agent_session.py b/openhands/server/session/agent_session.py index f2a22235c6..27daf479fb 100644 --- a/openhands/server/session/agent_session.py +++ b/openhands/server/session/agent_session.py @@ -24,7 +24,7 @@ from openhands.runtime.base import Runtime from openhands.runtime.impl.remote.remote_runtime import RemoteRuntime from openhands.security import SecurityAnalyzer, options from openhands.storage.files import FileStore -from openhands.utils.async_utils import call_sync_from_async +from openhands.utils.async_utils import EXECUTOR, call_sync_from_async from openhands.utils.shutdown_listener import should_continue WAIT_TIME_BEFORE_CLOSE = 90 @@ -203,7 +203,7 @@ class AgentSession: end_state.save_to_session(self.sid, self.file_store, self.user_id) await self.controller.close() if self.runtime is not None: - self.runtime.close() + EXECUTOR.submit(self.runtime.close) if self.security_analyzer is not None: await self.security_analyzer.close()