Skip output lines that have UTF8 decoding error (#441)

* Avoid crash if non-UTF8 character is encountered in output

Signed-off-by: benrichard-amd <ben.richard@amd.com>

* Ignore lines with non-UTF-8 characters. Do not print error.

Signed-off-by: benrichard-amd <ben.richard@amd.com>

* Remove trailing whitespace

Signed-off-by: benrichard-amd <ben.richard@amd.com>

---------

Signed-off-by: benrichard-amd <ben.richard@amd.com>

[ROCm/rocprofiler-compute commit: fb210abcd0]
このコミットが含まれているのは:
Ben Richard authored and GitHub committed 2024-10-03 11:27:55 -04:00
1 親 83de3f34ae
コミット 4da8b0dc46
1ファイル変更
+12 -8
+12 -8
ファイルの表示
@@ -205,14 +205,18 @@ def capture_subprocess_output(subprocess_args, new_env=None, profileMode=False):
buf = io.StringIO()
def handle_output(stream, mask):
# Because the process' output is line buffered, there's only ever one
# line to read when this function is called
line = stream.readline()
buf.write(line)
if profileMode:
console_log(rocprof_cmd, line.strip(), indent_level=1)
else:
console_log(line.strip())
try:
# Because the process' output is line buffered, there's only ever one
# line to read when this function is called
line = stream.readline()
buf.write(line)
if profileMode:
console_log(rocprof_cmd, line.strip(), indent_level=1)
else:
console_log(line.strip())
except UnicodeDecodeError:
# Skip this line
pass
# Register callback for an "available for read" event from subprocess' stdout stream
selector = selectors.DefaultSelector()