Skip to content

Commit

Permalink
Skip output lines that have UTF8 decoding error (#441)
Browse files Browse the repository at this point in the history
* Avoid crash if non-UTF8 character is encountered in output

Signed-off-by: benrichard-amd <[email protected]>

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

Signed-off-by: benrichard-amd <[email protected]>

* Remove trailing whitespace

Signed-off-by: benrichard-amd <[email protected]>

---------

Signed-off-by: benrichard-amd <[email protected]>
  • Loading branch information
benrichard-amd authored Oct 3, 2024
1 parent c8a1add commit fb210ab
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fb210ab

Please sign in to comment.