You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using psutil to return cpu usage for each core. From the python interpreter this works correctly, however from a script it does not.
Both are using the same python version.
The code I run is
In both cases, this returns no errors.
When executing the script, I get values such as [0.0, 0.0, 0.0, 0.0] and [0.0, 0.0, 100.0, 0.0]
Running htop proves that cpu usage is different and that all cores are used.
Even rebooting failed to help.
The text was updated successfully, but these errors were encountered:
Warning: the first time this function (psutil.cpu_percent()) is called with interval = 0.0 or None it will return a meaningless 0.0 value which you are supposed to ignore.
Translated: to get meaningful values you have to call psutil.cpu_percent() in a loop with an interval:
while 1:
print(psutil.cpu_percent())
time.sleep(1)
Summary
Description
I am using psutil to return cpu usage for each core. From the python interpreter this works correctly, however from a script it does not.
Both are using the same python version.
The code I run is
In both cases, this returns no errors.
When executing the script, I get values such as
[0.0, 0.0, 0.0, 0.0]
and[0.0, 0.0, 100.0, 0.0]
Running htop proves that cpu usage is different and that all cores are used.
Even rebooting failed to help.
The text was updated successfully, but these errors were encountered: