mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Fixes for minor cases where FDs were not closed (#6228)
This commit is contained in:
parent
99eda0e571
commit
b9884f7609
@ -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(
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user