[PATCH v3 3/5] dts: add timeout override option to interactive shells
Patrick Robb
probb at iol.unh.edu
Wed Jul 2 07:21:52 CEST 2025
From: Nicholas Pratte <npratte at iol.unh.edu>
Add an extra parameter to the interactive shell send command
to handle function to allow for a 1 time override of the send
command timeout.
Bugzilla ID: 1697
Signed-off-by: Nicholas Pratte <npratte at iol.unh.edu>
Signed-off-by: Patrick Robb <probb at iol.unh.edu>
Reviewed-by: Dean Marx <dmarx at iol.unh.edu>
---
dts/framework/remote_session/interactive_shell.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dts/framework/remote_session/interactive_shell.py b/dts/framework/remote_session/interactive_shell.py
index ba8489eafa..5331b8c7d1 100644
--- a/dts/framework/remote_session/interactive_shell.py
+++ b/dts/framework/remote_session/interactive_shell.py
@@ -177,7 +177,11 @@ def start_application(self, prompt: str | None = None) -> None:
get_ctx().shell_pool.register_shell(self)
def send_command(
- self, command: str, prompt: str | None = None, skip_first_line: bool = False
+ self,
+ command: str,
+ prompt: str | None = None,
+ skip_first_line: bool = False,
+ added_timeout: int = 0,
) -> str:
"""Send `command` and get all output before the expected ending string.
@@ -195,6 +199,7 @@ def send_command(
prompt: After sending the command, `send_command` will be expecting this string.
If :data:`None`, will use the class's default prompt.
skip_first_line: Skip the first line when capturing the output.
+ added_timeout: additional duration for a given command, if needed.
Returns:
All output in the buffer before expected string.
@@ -213,6 +218,7 @@ def send_command(
self._logger.info(f"Sending: '{command}'")
if prompt is None:
prompt = self._default_prompt
+ self._ssh_channel.settimeout(self._timeout + added_timeout)
out: str = ""
try:
self._stdin.write(f"{command}{self._command_extra_chars}\n")
@@ -236,6 +242,7 @@ def send_command(
self._node.main_session.interactive_session.hostname
) from e
finally:
+ self._ssh_channel.settimeout(self._timeout)
self._logger.debug(f"Got output: {out}")
return out
--
2.49.0
More information about the dev
mailing list