summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2018-04-13 04:52:55 -0400
committerGitHub <noreply@github.com>2018-04-13 04:52:55 -0400
commit34e98b6e2a5739f9e633436e8cd61f3246c1091e (patch)
tree21473ba822b34ae5d030fe7ba021127e130e52bc /docs
parent1e63ab355d592fefd77c819fb642fe6d7963f295 (diff)
downloadpsutil-34e98b6e2a5739f9e633436e8cd61f3246c1091e.tar.gz
771 Windows CPU count (#1257)
* use GetLogicalProcessorInformation() to get logical cpu_count() * return None if cpu_count() is undetermined + add mock test * style * factor out logical CPU num fun * remove unused code * psutil_get_num_cpus(): provide an option to fail on err * add comments * reuse get_num_cpus() function * error out if get_num_cpus() fail * use GetLogicalProcessorInformationEx to get phys CPU num * on win vista/xp just return None for phys CPU count * rename vars * fix C compiler warnings + remove mingw workarounds * return None if phys cpu count cant' be determined; update HISTORY * update HISTORY * update doc * add WMI tests * refactor tests * print debug msg for cpu phys returning None on win < 7 * try to fix win test * appveyor debug * fix typo * adjust appveyor 64 bit versions * debug msg * fix for loop * re-enable python versions * (maybe) finally fix GetLogicalProcessorInformationEx return len
Diffstat (limited to 'docs')
-rw-r--r--docs/index.rst17
1 files changed, 9 insertions, 8 deletions
diff --git a/docs/index.rst b/docs/index.rst
index 395fd688..548f361f 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -164,15 +164,11 @@ CPU
Return the number of logical CPUs in the system (same as
`os.cpu_count() <http://docs.python.org/3/library/os.html#os.cpu_count>`__
in Python 3.4) or ``None`` if undetermined.
- This number may not be equivalent to the number of CPUs the current process
- can actually use in case process CPU affinity has been changed or Linux
- cgroups are being used.
- The number of usable CPUs can be obtained with
- ``len(psutil.Process().cpu_affinity())``.
If *logical* is ``False`` return the number of physical cores only (hyper
- thread CPUs are excluded).
+ thread CPUs are excluded) or ``None`` if undetermined.
On OpenBSD and NetBSD ``psutil.cpu_count(logical=False)`` always return
- ``None``. Example on a system having 2 physical hyper-thread CPU cores:
+ ``None``.
+ Example on a system having 2 physical hyper-thread CPU cores:
>>> import psutil
>>> psutil.cpu_count()
@@ -180,7 +176,12 @@ CPU
>>> psutil.cpu_count(logical=False)
2
- Example returning the number of CPUs usable by the current process:
+ Note that this number is not equivalent to the number of CPUs the current
+ process can actually use.
+ That can vary in case process CPU affinity has been changed, Linux cgroups
+ are being used or on Windows systems using processor groups or having more
+ than 64 CPUs.
+ The number of usable CPUs can be obtained with:
>>> len(psutil.Process().cpu_affinity())
1