Skip to content

Commit

Permalink
fix(api/libnvml): ignore UTF-8 decoding errors from pynvml
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Jul 12, 2024
1 parent 6bc8a8b commit 56940d1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nvitop/api/libnvml.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,11 @@ def nvmlQuery(
except AttributeError as e1:
raise NVMLError_FunctionNotFound from e1

retval = func(*args, **kwargs) # type: ignore[operator]
except NVMLError_FunctionNotFound as e2:
try:
retval = func(*args, **kwargs) # type: ignore[operator]
except UnicodeDecodeError as e2:
raise NVMLError_Unknown from e2
except NVMLError_FunctionNotFound as e3:
if not ignore_function_not_found:
identifier = (
func
Expand All @@ -443,7 +446,7 @@ def nvmlQuery(
identifier not in UNKNOWN_FUNCTIONS
and len(UNKNOWN_FUNCTIONS) < UNKNOWN_FUNCTIONS_CACHE_SIZE
):
UNKNOWN_FUNCTIONS[identifier] = (func, e2)
UNKNOWN_FUNCTIONS[identifier] = (func, e3)
LOGGER.exception(
(
'ERROR: A FunctionNotFound error occurred while calling %s.\n'
Expand Down

0 comments on commit 56940d1

Please sign in to comment.