There exists some inconsistencies in the successful initialization of interactive applications within remote sessions. On some testbeds, there is a consistent failure in the first start-up attempt of an application, and 'stdin' and 'stdout' buffered pipes also indicate improper deallocation.
The issue stems from a remote server's inability to fully exit out of an interactive application before the complete clean up of the SingleInteractiveShell context manager. Moreover, the experience of buffered pipe or related exceptions as a result of 'stdin' and 'stdout' buffered pipes is a result of the context manager's cleanup process. Explicit calls to close the 'stdin' buffered pipe is needless and this is done via a 'Channel.close()' within Paramiko. The following patch corrects these issues. Bugzilla ID: 1597 Signed-off-by: Nicholas Pratte <npra...@iol.unh.edu> --- .../remote_session/single_active_interactive_shell.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/single_active_interactive_shell.py b/dts/framework/remote_session/single_active_interactive_shell.py index e3f6424e97..90ba862dbb 100644 --- a/dts/framework/remote_session/single_active_interactive_shell.py +++ b/dts/framework/remote_session/single_active_interactive_shell.py @@ -231,7 +231,13 @@ def send_command( return out def _close(self) -> None: - self._stdin.close() + try: + # Ensure the primary application has terminated via readiness of 'stdout'. + self._ssh_channel.recv(1) # 'Waits' for a single byte to enter 'stdout' buffer. + except TimeoutError as e: + self._logger.exception(e) + self._logger.debug("Application failed to exit before set timeout.") + raise InteractiveSSHTimeoutError("Application 'exit' command") from e self._ssh_channel.close() def _update_real_path(self, path: PurePath) -> None: -- 2.44.0