To expose certain attributes, the psutil module performs python magic
that results in an attribute being present in the module, but not in
the __all__ list. As pylint uses the __all__ list to determine whether
property accesses are errors, it is understandably confused about this
state of affairs.

To fix this, we just use the newer cpu_count attribute which is
supposed to replace NUM_CPUS anyway.

Signed-off-by: Hrvoje Ribicic <[email protected]>
---
 lib/hypervisor/hv_kvm/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/hypervisor/hv_kvm/__init__.py 
b/lib/hypervisor/hv_kvm/__init__.py
index 2404d93..17b5496 100644
--- a/lib/hypervisor/hv_kvm/__init__.py
+++ b/lib/hypervisor/hv_kvm/__init__.py
@@ -725,7 +725,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
 
     target_process = psutil.Process(process_id)
     if cpus == constants.CPU_PINNING_OFF:
-      target_process.set_cpu_affinity(range(psutil.NUM_CPUS))
+      target_process.set_cpu_affinity(range(psutil.cpu_count()))
     else:
       target_process.set_cpu_affinity(cpus)
 
-- 
2.0.0.526.g5318336

Reply via email to