From 58ab67ea316513af7abcf182de4e553287fa248a Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Fri, 20 Mar 2020 10:35:25 +0200 Subject: [PATCH] Fix execution output handling --- trains_agent/commands/worker.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/trains_agent/commands/worker.py b/trains_agent/commands/worker.py index 9403894..5d14b74 100644 --- a/trains_agent/commands/worker.py +++ b/trains_agent/commands/worker.py @@ -763,9 +763,13 @@ class Worker(ServiceCommandSection): def _print_file(file_path, prev_line_count): with open(file_path, "rb") as f: binary_text = f.read() + if not binary_text: + return [] # skip the previously printed lines, blines = binary_text.split(b'\n')[prev_line_count:] - return decode_binary_lines(blines) + if not blines: + return blines + return decode_binary_lines(blines if blines[-1] else blines[:-1]) stdout = open(stdout_path, "wt") stderr = open(stderr_path, "wt") if stderr_path else stdout