-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Linux] Differences between psutil.cpu_freq(True) and psutil.cpu_count() #1472
Comments
Mh... annoying. Looking back at how this code is implemented, it looks like we may want to try something different. Instead of for x in range(psutil.cpu_count(logical=True)):
if os.path.exists("/sys/devices/system/cpu/cpufreq/policy%s" % x):
...
elif os.path.exists("/sys/devices/system/cpu/cpu%s/cpufreq" % x):
...
else:
break It seems to me this will be more robust. |
...or possibly this: def cpu_freq():
def get_path(num):
for p in ("/sys/devices/system/cpu/cpufreq/policy%s" % num,
"/sys/devices/system/cpu/cpu%s/cpufreq" % num):
if os.path.exists(p):
return p
for n in range(psutil.cpu_count(logical=True)):
path = get_path(n)
if not path:
break
... |
Merged
giampaolo
added a commit
that referenced
this issue
Apr 11, 2019
nlevitt
added a commit
to nlevitt/psutil
that referenced
this issue
May 6, 2019
* origin/master: Fix giampaolo#1276: [AIX] use getargs to get process cmdline (giampaolo#1500) (patch by @wiggin15) Fix Process.ionice example using wrong keyword arg (giampaolo#1504) fix history syntax remove catching IOError; let the test fail and adjust it later Fix cpu freq (giampaolo#1496) pre release fix giampaolo#1493: [Linux] cpu_freq(): handle the case where /sys/devices/system/cpu/cpufreq/ exists but is empty. Revert "Fix cpu_freq (giampaolo#1493)" (giampaolo#1495) Fix cpu_freq (giampaolo#1493) Update cpu_freq to return 0 for max/min if not available (giampaolo#1487) give CREDITS to @agnewee for giampaolo#1491 SunOS / net_if_addrs(): free() ifap struct on error (giampaolo#1491) fix giampaolo#1486: add wraps() decorator around wrap_exceptions refactor/move some utilities into _common.py update doc update HISTORY Implement getloadavg on Windows. Fixes giampaolo#604 and giampaolo#1484 (giampaolo#1485) (patch by Ammar Askar) give credits to @amanusk for giampaolo#1472
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rasbperry pi 3
Bug description
Wonder about behaviour:
psutil.cpu_freq(percpu=True)
, on a Raspberry pi 3 now returns:[scpufreq(current=600.0, min=600.0, max=1200.0)]
i.e. only 1 CPUWhen both
psutil.cpu_count(logical=False)
andpsutil.cpu_count(logical=True)
return4
: The expected behaviour.Looking at the code, it seems this is because on the Pi,
there is only
/sys/devices/system/cpu/cpufreq/policy0
while there areAnd the former is checked first.
Should this be compared to
psutil.cpu_count(logical=False)
, and the more accurate result taken?Should I open a PR for this?
The text was updated successfully, but these errors were encountered: