From 526854b56ed8f45542f6ef77d48405cfebc97fa2 Mon Sep 17 00:00:00 2001 From: Lukasz Tekieli Date: Wed, 25 Feb 2026 16:11:06 +0100 Subject: [PATCH] Fix ssh out collection flakiness --- score/itf/core/com/ssh.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/score/itf/core/com/ssh.py b/score/itf/core/com/ssh.py index 13fb270..3303d7c 100644 --- a/score/itf/core/com/ssh.py +++ b/score/itf/core/com/ssh.py @@ -272,6 +272,21 @@ def _read_output_with_timeout(stream, logger_in, log, max_exec_time, separate_st continue if channel.exit_status_ready(): + # Do not stop immediately on exit status; first ensure there is no + # more channel activity pending. This avoids truncating final output + # that may still be in-flight after process termination. + remaining = deadline - now + wait_after_exit = 0 if remaining <= 0 else min(0.1, remaining) + ready, _, _ = select.select([channel], [], [], wait_after_exit) + has_stdout = channel.recv_ready() + has_stderr = separate_stderr and channel.recv_stderr_ready() + + if has_stdout or has_stderr: + continue + + # If select reports readiness but there is no buffered stdout/stderr, + # this typically indicates EOF/control-channel readiness, so capture + # can be completed safely. break # Avoid busy-waiting. Paramiko Channel supports fileno() on POSIX, so we can