Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jul 31, 2023
1 parent 96c8fcb commit c609d24
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
14 changes: 12 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@

XXXX-XX-XX

- 2241_, [NetBSD]: can't compile On NetBSD 10.99.3/amd64. (patch by Thomas
Klausner)
**Enhancements**

- 1703_: `cpu_percent()`_ and `cpu_times_percent()`_ are now thread safe,
meaning they can be called from different threads and still return
meaningful and independent results. Before, if (say) 10 threads called
``cpu_percent(interval=None)`` at the same time, only 1 thread out of 10
would get the right result.
- 2266_: if `Process`_ class is passed a very high PID, raise `NoSuchProcess`_
instead of OverflowError. (patch by Xuehai Pan)

**Bug fixes**

- 2241_, [NetBSD]: can't compile On NetBSD 10.99.3/amd64. (patch by Thomas
Klausner)
- 2268_: ``bytes2human()`` utility function was unable to properly represent
negative values.

Expand Down
9 changes: 9 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ CPU
utilization as a percentage for each CPU.
First element of the list refers to first CPU, second element to second CPU
and so on. The order of the list is consistent across calls.
Internally this function maintains a global map (a dict) where each key is
the ID of the calling thread (`threading.get_ident`_). This means it can be
called from different threads, at different intervals, and still return
meaningful and independent results.

>>> import psutil
>>> # blocking
Expand All @@ -194,6 +198,8 @@ CPU
it will return a meaningless ``0.0`` value which you are supposed to
ignore.

.. versionchanged:: 5.9.6 function is now thread safe.

.. function:: cpu_times_percent(interval=None, percpu=False)

Same as :func:`cpu_percent()` but provides utilization percentages for each
Expand All @@ -212,6 +218,8 @@ CPU
.. versionchanged::
4.1.0 two new *interrupt* and *dpc* fields are returned on Windows.

.. versionchanged:: 5.9.6 function is now thread safe.

.. function:: cpu_count(logical=True)

Return the number of logical CPUs in the system (same as `os.cpu_count`_
Expand Down Expand Up @@ -3052,6 +3060,7 @@ Timeline
.. _`subprocess.Popen`: https://docs.python.org/3/library/subprocess.html#subprocess.Popen
.. _`temperatures.py`: https://github.com/giampaolo/psutil/blob/master/scripts/temperatures.py
.. _`TerminateProcess`: https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-terminateprocess
.. _`threading.get_ident`: https://docs.python.org/3/library/threading.html#threading.get_ident
.. _`threading.Thread`: https://docs.python.org/3/library/threading.html#threading.Thread
.. _Tidelift security contact: https://tidelift.com/security
.. _Tidelift Subscription: https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme
2 changes: 1 addition & 1 deletion psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
AF_LINK = _psplatform.AF_LINK

__author__ = "Giampaolo Rodola'"
__version__ = "5.9.5"
__version__ = "5.9.6"
version_info = tuple([int(num) for num in __version__.split('.')])

_timer = getattr(time, 'monotonic', time.time)
Expand Down

0 comments on commit c609d24

Please sign in to comment.