Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MattiasMartens opened this issue May 10, 2022 · 1 comment · Fixed by #57
Closed

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

MattiasMartens opened this issue May 10, 2022 · 1 comment · Fixed by #57
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@MattiasMartens
Copy link

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):

  • OS: 5.10.104-linuxkit
  • Python version: 3.9.12
  • Pytest version: 6.2.1
  • pytest-monitor version: 1.6.3
@js-dieu
Copy link
Collaborator

js-dieu commented May 12, 2022

Hello @MattiasMartens

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

Keep you posted

@js-dieu js-dieu added bug Something isn't working documentation Improvements or additions to documentation labels May 12, 2022
@js-dieu js-dieu self-assigned this May 12, 2022
@js-dieu js-dieu mentioned this issue May 18, 2022
14 tasks
js-dieu added a commit that referenced this issue May 18, 2022
* Fix - #56: Force CPU frequency to 0 when unable to fetch it.

On some system, it appears to not be feasible to fetch the frequency.
Under such circumstances, the CPU frequency is set to 0 and a warning
is emited.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants