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
2024-10-03 11:27:55 -04:00
коммит произвёл GitHub
родитель 83de3f34ae
Коммит 4da8b0dc46
+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()