The Wayback Machine - https://web.archive.org/web/20200608053847/https://github.com/giampaolo/psutil/issues/1456
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

[CentOS] cpu_freq does not return proper type in some cases #1456

Open
cschanzlenist opened this issue Mar 11, 2019 · 3 comments
Open

[CentOS] cpu_freq does not return proper type in some cases #1456

cschanzlenist opened this issue Mar 11, 2019 · 3 comments
Assignees
Labels
bug

Comments

@cschanzlenist
Copy link

@cschanzlenist cschanzlenist commented Mar 11, 2019

Linux
CentOS 7.6
Name: psutil
Version: 5.6.1

Per https://psutil.readthedocs.io/en/latest/ , cpu_freq should return 0 if min and max cannot be determined.

However, the code (_pslinux.py line 722) can return None, which breaks the s-util package I was trying to use due to a type mismatch.

Either the documentation should be corrected or the code (likely the code) with:

722c722
<                     ret.append(_common.scpufreq(float(value), None, None))
---
>                     ret.append(_common.scpufreq(float(value), 0.0, 0.0))

For others to reference/find, here's the traceback that s-tui experienced:

$ s-tui 
Traceback (most recent call last):
  File "/home/user/venv/bin/s-tui", line 11, in <module>
    sys.exit(main())
  File "/home/user/venv/lib/python3.6/site-packages/s_tui/s_tui.py", line 927, in main
    graph_controller = GraphController(args)
  File "/home/user/venv/lib/python3.6/site-packages/s_tui/s_tui.py", line 728, in __init__
    self.view = GraphView(self)
  File "/home/user/venv/lib/python3.6/site-packages/s_tui/s_tui.py", line 233, in __init__
    urwid.WidgetPlaceholder.__init__(self, self.main_window())
  File "/home/user/venv/lib/python3.6/site-packages/s_tui/s_tui.py", line 531, in main_window
    freq_source = FreqSource(is_admin)
  File "/home/user/venv/lib/python3.6/site-packages/s_tui/Sources/FreqSource.py", line 118, in __init__
    if self.last_freq >= 0 and self.top_freq <= 0:
TypeError: '<=' not supported between instances of 'NoneType' and 'int'

@giampaolo
Copy link
Owner

@giampaolo giampaolo commented Apr 11, 2019

Can you make a PR?

@cschanzlenist
Copy link
Author

@cschanzlenist cschanzlenist commented Apr 11, 2019

IF PR means pull request, sorry, no - not an experience git user and don't have a couple hours to learn right now. :-) The one-liner fix is above.

@amanusk
Copy link
Collaborator

@amanusk amanusk commented Apr 12, 2019

@cschanzlenist, @giampaolo if it's OK by you, I have opened a PR to fix the issue #1487

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.