Fix curious psutil lint error
authorHrvoje Ribicic <riba@google.com>
Tue, 15 Jul 2014 18:26:52 +0000 (20:26 +0200)
committerHrvoje Ribicic <riba@google.com>
Thu, 17 Jul 2014 14:31:31 +0000 (16:31 +0200)
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 <riba@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

lib/hypervisor/hv_kvm/__init__.py

index 2404d93..17b5496 100644 (file)
@@ -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)