Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Change timeout to float

Jakub Novak06c59f881c53
diff --git a/packages/python-sdk/e2b/session/filesystem.py b/packages/python-sdk/e2b/session/filesystem.py
index d2bcfc94b..074bbdeef 100644
--- a/packages/python-sdk/e2b/session/filesystem.py
+++ b/packages/python-sdk/e2b/session/filesystem.py
@@ -55,7 +55,7 @@ class FilesystemManager:
# self.service_name, "writeBase64", [path, base64_content]
# )
- async def read(self, path: str, timeout: Optional[int] = TIMEOUT) -> str:
+ async def read(self, path: str, timeout: Optional[float] = TIMEOUT) -> str:
"""
Reads the whole content of a file as an array of bytes.
@@ -74,7 +74,7 @@ class FilesystemManager:
raise FilesystemException(e.message) from e
async def write(
- self, path: str, content: str, timeout: Optional[int] = TIMEOUT
+ self, path: str, content: str, timeout: Optional[float] = TIMEOUT
) -> None:
"""
Writes content to a file.
@@ -92,7 +92,7 @@ class FilesystemManager:
except RpcException as e:
raise FilesystemException(e.message) from e
- async def remove(self, path: str, timeout: Optional[int] = TIMEOUT) -> None:
+ async def remove(self, path: str, timeout: Optional[float] = TIMEOUT) -> None:
"""
Removes a file or a directory.
@@ -108,7 +108,7 @@ class FilesystemManager:
except RpcException as e:
raise FilesystemException(e.message) from e
- async def list(self, path: str, timeout: Optional[int] = TIMEOUT) -> List[FileInfo]:
+ async def list(self, path: str, timeout: Optional[float] = TIMEOUT) -> List[FileInfo]:
"""
List files in a directory.
@@ -130,7 +130,7 @@ class FilesystemManager:
except RpcException as e:
raise FilesystemException(e.message) from e
- async def make_dir(self, path: str, timeout: Optional[int] = TIMEOUT) -> None:
+ async def make_dir(self, path: str, timeout: Optional[float] = TIMEOUT) -> None:
"""
Creates a new directory and all directories along the way if needed on the specified path.
diff --git a/packages/python-sdk/e2b/session/filesystem_watcher.py b/packages/python-sdk/e2b/session/filesystem_watcher.py
index ead0f010d..8cf761fb4 100644
--- a/packages/python-sdk/e2b/session/filesystem_watcher.py
+++ b/packages/python-sdk/e2b/session/filesystem_watcher.py
@@ -49,7 +49,7 @@ class FilesystemWatcher:
self._unsubscribe: Optional[Callable[[], Awaitable[Any]]] = None
self._listeners: Set[Callable[[FilesystemEvent], Any]] = set()
- async def start(self, timeout: Optional[int] = TIMEOUT) -> None:
+ async def start(self, timeout: Optional[float] = TIMEOUT) -> None:
"""
Starts the filesystem watcher.
diff --git a/packages/python-sdk/e2b/session/main.py b/packages/python-sdk/e2b/session/main.py
index 206fea4ec..6d2e5f3d7 100644
--- a/packages/python-sdk/e2b/session/main.py
+++ b/packages/python-sdk/e2b/session/main.py
@@ -102,7 +102,7 @@ class Session(SessionConnection):
self._filesystem = FilesystemManager(session=self)
self._process = ProcessManager(session=self)
- async def open(self, timeout: Optional[int] = TIMEOUT) -> None:
+ async def open(self, timeout: Optional[float] = TIMEOUT) -> None:
"""
Opens the session.
@@ -135,7 +135,7 @@ class Session(SessionConnection):
id: Union[Environment, str],
api_key: Optional[str] = None,
on_scan_ports: Optional[Callable[[List[OpenPort]], Any]] = None,
- timeout: Optional[int] = TIMEOUT,
+ timeout: Optional[float] = TIMEOUT,
_debug_hostname: Optional[str] = None,
_debug_port: Optional[int] = None,
_debug_dev_env: Optional[Literal["remote", "local"]] = None,
diff --git a/packages/python-sdk/e2b/session/process.py b/packages/python-sdk/e2b/session/process.py
index 75de77c83..1077cc252 100644
--- a/packages/python-sdk/e2b/session/process.py
+++ b/packages/python-sdk/e2b/session/process.py
@@ -140,7 +140,7 @@ class Process:
self._finished = finished
self._output = output
- async def send_stdin(self, data: str, timeout: Optional[int] = TIMEOUT) -> None:
+ async def send_stdin(self, data: str, timeout: Optional[float] = TIMEOUT) -> None:
"""
Sends data to the process stdin.
@@ -157,7 +157,7 @@ class Process:
except RpcException as e:
raise ProcessException(e.message) from e
- async def kill(self, timeout: Optional[int] = TIMEOUT) -> None:
+ async def kill(self, timeout: Optional[float] = TIMEOUT) -> None:
"""
Kills the process.
@@ -198,7 +198,7 @@ class ProcessManager:
env_vars: Optional[EnvVars] = None,
rootdir: str = "",
process_id: Optional[str] = None,
- timeout: Optional[int] = TIMEOUT,
+ timeout: Optional[float] = TIMEOUT,
) -> Process:
"""
Starts a process in the environment.
@@ -287,7 +287,7 @@ class ProcessManager:
async def exit_handler():
await future_exit
logger.info(
- f"Handling process exit {self._service_name} (id: {process_id})",
+ f"Handling process exit (id: {process_id})",
)
if unsub_all:
await unsub_all()
@@ -302,7 +302,7 @@ class ProcessManager:
self._process_cleanup.append(exit_task.cancel)
async def trigger_exit():
- logger.info(f"Exiting the process {self._service_name} (id: {process_id})")
+ logger.info(f"Exiting the process (id: {process_id})")
future_exit(None)
await future_exit_handler_finish
logger.debug(f"Exited the process (id: {process_id})")
diff --git a/packages/python-sdk/e2b/session/session_connection.py b/packages/python-sdk/e2b/session/session_connection.py
index 8149c2898..d237eace7 100644
--- a/packages/python-sdk/e2b/session/session_connection.py
+++ b/packages/python-sdk/e2b/session/session_connection.py
@@ -220,7 +220,7 @@ class SessionConnection:
service: str,
method: str,
params: List[Any] = None,
- timeout: Optional[int] = TIMEOUT,
+ timeout: Optional[float] = TIMEOUT,
):
if not params:
params = []
@@ -274,7 +274,7 @@ class SessionConnection:
return unsub_all
- async def _unsubscribe(self, sub_id: str, timeout: Optional[int] = TIMEOUT):
+ async def _unsubscribe(self, sub_id: str, timeout: Optional[float] = TIMEOUT):
sub = self._subscribers[sub_id]
await self._call(sub.service, "unsubscribe", [sub.id], timeout=timeout)
del self._subscribers[sub_id]
@@ -286,7 +286,7 @@ class SessionConnection:
handler: Callable[[Any], Any],
method: str,
*params,
- timeout: Optional[int] = TIMEOUT,
+ timeout: Optional[float] = TIMEOUT,
):
sub_id = await self._call(
service, "subscribe", [method, *params], timeout=timeout
diff --git a/packages/python-sdk/e2b/session/terminal.py b/packages/python-sdk/e2b/session/terminal.py
index 952a2bdf5..79d7d305c 100644
--- a/packages/python-sdk/e2b/session/terminal.py
+++ b/packages/python-sdk/e2b/session/terminal.py
@@ -71,7 +71,7 @@ class Terminal:
self._finished = finished
self._output = output
- async def send_data(self, data: str, timeout: Optional[int] = TIMEOUT) -> None:
+ async def send_data(self, data: str, timeout: Optional[float] = TIMEOUT) -> None:
"""
Sends data to the terminal standard input.
@@ -89,7 +89,7 @@ class Terminal:
raise TerminalException(e.message) from e
async def resize(
- self, cols: int, rows: int, timeout: Optional[int] = TIMEOUT
+ self, cols: int, rows: int, timeout: Optional[float] = TIMEOUT
) -> None:
"""
Resizes the terminal tty.
@@ -108,7 +108,7 @@ class Terminal:
except RpcException as e:
raise TerminalException(e.message) from e
- async def kill(self, timeout: Optional[int] = TIMEOUT) -> None:
+ async def kill(self, timeout: Optional[float] = TIMEOUT) -> None:
"""
Kill the terminal session.
@@ -153,7 +153,7 @@ class TerminalManager:
on_exit: Optional[Callable[[], Any]] = None,
cmd: Optional[str] = None,
env_vars: Optional[EnvVars] = None,
- timeout: Optional[int] = TIMEOUT,
+ timeout: Optional[float] = TIMEOUT,
) -> Terminal:
"""
Start a new terminal session.