Skip to content

Commit

Permalink
Change timeout to float
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Aug 31, 2023
1 parent d11978f commit 06c59f8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions packages/python-sdk/e2b/session/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, session: SessionConnection):
# 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.
Expand All @@ -74,7 +74,7 @@ async def read(self, path: str, timeout: Optional[int] = TIMEOUT) -> str:
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.
Expand All @@ -92,7 +92,7 @@ async def write(
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.
Expand All @@ -108,7 +108,7 @@ async def remove(self, path: str, timeout: Optional[int] = TIMEOUT) -> None:
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.
Expand All @@ -130,7 +130,7 @@ async def list(self, path: str, timeout: Optional[int] = TIMEOUT) -> List[FileIn
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.
Expand Down
2 changes: 1 addition & 1 deletion packages/python-sdk/e2b/session/filesystem_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(
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.
Expand Down
4 changes: 2 additions & 2 deletions packages/python-sdk/e2b/session/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
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.
Expand Down Expand Up @@ -135,7 +135,7 @@ async def create(
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,
Expand Down
10 changes: 5 additions & 5 deletions packages/python-sdk/e2b/session/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __init__(
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.
Expand All @@ -157,7 +157,7 @@ async def send_stdin(self, data: str, timeout: Optional[int] = TIMEOUT) -> None:
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.
Expand Down Expand Up @@ -198,7 +198,7 @@ async def start(
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.
Expand Down Expand Up @@ -287,7 +287,7 @@ def handle_stderr(data: Dict[Any, Any]):
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()
Expand All @@ -302,7 +302,7 @@ async def exit_handler():
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})")
Expand Down
6 changes: 3 additions & 3 deletions packages/python-sdk/e2b/session/session_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async def _call(
service: str,
method: str,
params: List[Any] = None,
timeout: Optional[int] = TIMEOUT,
timeout: Optional[float] = TIMEOUT,
):
if not params:
params = []
Expand Down Expand Up @@ -274,7 +274,7 @@ async def unsub_all():

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]
Expand All @@ -286,7 +286,7 @@ async def _subscribe(
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
Expand Down
8 changes: 4 additions & 4 deletions packages/python-sdk/e2b/session/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
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.
Expand All @@ -89,7 +89,7 @@ async def send_data(self, data: str, timeout: Optional[int] = TIMEOUT) -> None:
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.
Expand All @@ -108,7 +108,7 @@ async def resize(
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.
Expand Down Expand Up @@ -153,7 +153,7 @@ async def start(
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.
Expand Down

0 comments on commit 06c59f8

Please sign in to comment.