[BUG] failure to count cpus when cpusets used
Describe the bug
When cgroups (systemd slices) are used to restrict the user to a subset of all cpus the cpu count fails and bpytop fails
To Reproduce
- have an ubuntu 21.10
- set up a system slice for two cores and an user slice for the remaining cores
- as an user run bpytop
Expected behavior
bpytop runs
bpytop version: 1.0.61 psutil version: 5.8.0
Ubuntu 21.10 gnome terminal inconsolata, size 16 Python 3.9.7
Additional context At line 259 THREADS is defined as psutil.cpu_count(logical=True). Later this number is used to create the cls.cpu_whatever lists Then a few pages below psutil.cpu_percent(percpu=True) is used to iterate through this array..
but:
psutil.cpu_count(logical=True) 10 len(psutil.cpu_percent(percpu=True)) 12
Changing the original sin line to this: THREADS: int = len(psutil.cpu_percent(percpu=True)) or 1 fixes the bug.
error.log The log is full with my debug prints, sorry.