* Catch case where object does not have thumbnail data

* Catch intel stats json decoding error

* Catch division by zero
This commit is contained in:
Nicolas Mowen 2024-10-21 08:38:48 -06:00 committed by GitHub
parent 8fcb8e54f7
commit 560dc68120
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -344,6 +344,7 @@ class CameraState:
# if the object's thumbnail is not from the current frame, skip
if (
current_frame is None
or obj.thumbnail_data is None
or obj.false_positive
or obj.thumbnail_data["frame_time"] != frame_time
):

View File

@ -279,7 +279,11 @@ def get_intel_gpu_stats() -> dict[str, str]:
logger.error(f"Unable to poll intel GPU stats: {p.stderr}")
return None
else:
data = json.loads(f'[{"".join(p.stdout.split())}]')
try:
data = json.loads(f'[{"".join(p.stdout.split())}]')
except json.JSONDecodeError:
return {"gpu": "-%", "mem": "-%"}
results: dict[str, str] = {}
render = {"global": []}
video = {"global": []}
@ -328,7 +332,7 @@ def get_intel_gpu_stats() -> dict[str, str]:
results["clients"] = {}
for key in render.keys():
if key == "global":
if key == "global" or not render[key] or not video[key]:
continue
results["clients"][key] = (