Track "last lines" per-process instead of per-buffer, now that each process can have multiple active buffers (#485).

This commit is contained in:
Dan Helfman
2026-01-08 22:26:15 -08:00
parent 1299aefeff
commit 776bf3fcd4
+4 -4
View File
@@ -189,7 +189,7 @@ def log_outputs(processes, exclude_stdouts, output_log_level, borg_local_path, b
captured, in which case it won't be logged.
'''
# Map from output buffer to sequence of last lines.
buffer_last_lines = collections.defaultdict(list)
process_last_lines = collections.defaultdict(list)
process_for_output_buffer = {
buffer: process
for process in processes
@@ -242,7 +242,7 @@ def log_outputs(processes, exclude_stdouts, output_log_level, borg_local_path, b
borg_local_path=borg_local_path,
command=command,
),
last_lines=buffer_last_lines[ready_buffer],
last_lines=process_last_lines[ready_process],
captured_output=captured_outputs[ready_process],
)
@@ -263,11 +263,11 @@ def log_outputs(processes, exclude_stdouts, output_log_level, borg_local_path, b
exit_status = interpret_exit_code(command, exit_code, borg_local_path, borg_exit_codes)
if exit_status in {Exit_status.ERROR, Exit_status.WARNING}:
last_lines = process_last_lines[process]
# If an error occurs, include its output in the raised exception so that we don't
# inadvertently hide error output.
for output_buffer in output_buffers_for_process(process, exclude_stdouts):
last_lines = buffer_last_lines[output_buffer] if output_buffer else []
# Collect any straggling output lines that came in since we last gathered output.
while output_buffer: # pragma: no cover
line = output_buffer.readline().rstrip().decode()