Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Run runtime.close in background thread (#7524)

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