Fixes for minor cases where FDs were not closed (#6228)

This commit is contained in:
tofarr 2025-01-13 09:15:23 -07:00 committed by GitHub
parent 99eda0e571
commit b9884f7609
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View File

@ -18,10 +18,12 @@ from openhands.utils.shutdown_listener import (
class RemoteRuntimeBuilder(RuntimeBuilder):
"""This class interacts with the remote Runtime API for building and managing container images."""
def __init__(self, api_url: str, api_key: str):
def __init__(
self, api_url: str, api_key: str, session: requests.Session | None = None
):
self.api_url = api_url
self.api_key = api_key
self.session = requests.Session()
self.session = session or requests.Session()
self.session.headers.update({'X-API-Key': self.api_key})
def build(

View File

@ -66,7 +66,9 @@ class RemoteRuntime(ActionExecutionClient):
)
self.runtime_builder = RemoteRuntimeBuilder(
self.config.sandbox.remote_runtime_api_url, self.config.sandbox.api_key
self.config.sandbox.remote_runtime_api_url,
self.config.sandbox.api_key,
self.session,
)
self.runtime_id: str | None = None
self.runtime_url: str | None = None

View File

@ -48,6 +48,8 @@ def send_request(
_json = response.json()
except (requests.exceptions.JSONDecodeError, json.decoder.JSONDecodeError):
_json = None
finally:
response.close()
raise RequestHTTPError(
e,
response=e.response,