CFMTech / pytest-monitor

Pytest plugin for analyzing resource usage during test sessions
MIT License
173 stars 16 forks source link

Crash on __init__ if psutil.cpu_freq() gives no results #56

Closed MattiasMartens closed 2 years ago

MattiasMartens commented 2 years ago

Describe the bug When running on a system whose architecture is such that psutil.cpu_freq() returns None, pytest-monitor crashes pytest on startup:

AttributeError: 'NoneType' object has no attribute 'current'

To Reproduce

An example of an architecture with this problem is 5.10.104-linuxkit, the version used by the Docker image python:3.9-slim-buster.

As of the current version 5.9.0, psutil tries to find the CPU service in /sys/devices/system/cpu/cpufreq/policy0 or /sys/devices/system/cpu/cpu0/cpufreq; if it can't find it there, it checks /proc/cpuinfo for lines starting with cpu mhz. But that doesn't always work (in my case the CPU was given only in BogoMIPS). In that case it returns None, triggering this crash.

Expected behavior

Prefer that pytest-monitor fails gracefully in this case, or perhaps defaults CPU utilization to zero and emits a warning.

Desktop (please complete the following information):

js-dieu commented 2 years ago

Hello @MattiasMartens

Thanks for reporting. I'll strive to make a quickfix for that this week.

Keep you posted