Run runtime.close in background thread (#7524)

This commit is contained in:
tofarr 2025-03-26 12:12:59 -06:00 committed by GitHub
parent 400afeb70e
commit c5491e87aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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