python-psutil/mem-used-bsc1181475.patch
Dirk Mueller ee06b25cd4 - update to 5.9.5:
* in case of exception, display a cleaner error
    traceback by hiding the `KeyError` bit deriving from a
    missed cache hit.
  * print the full traceback when a `DeprecationWarning`
    or `UserWarning` is raised.
  * there are cases where `Process.cwd()`_ cannot be
    determined (e.g. directory no longer exists), in which case
    we returned either ``None`` or an empty string. 
    This was consolidated and we now return ``""`` on all
    platforms.
  * [UNIX]: if process is a zombie, and we can only
    determine part of the its truncated `Process.name()`_
    (15 chars), don't fail with `ZombieProcess`_ when we try
    to guess the full name from the `Process.cmdline()`_. Just
    return the truncated name.
  * on certain kernels, ``"MemAvailable"`` field
    from ``/proc/meminfo`` returns ``0`` (possibly a kernel bug), in
    which case we calculate an approximation for ``available``
    memory which matches "free" CLI utility.
  * `disk_partitions()`_: do not unnecessarily
    read /proc/filesystems and raise `AccessDenied`_ unless user
    specified `all=False` argument.
  * `users()`_ loses precision for ``started``
    attribute (off by 1 minute).
  * if cwd no longer exists. Return an empty string instead.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-psutil?expand=0&rev=156
2023-05-03 09:07:06 +00:00

35 lines
1.2 KiB
Diff

---
psutil/_pslinux.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: psutil-5.9.5/psutil/_pslinux.py
===================================================================
--- psutil-5.9.5.orig/psutil/_pslinux.py
+++ psutil-5.9.5/psutil/_pslinux.py
@@ -474,12 +474,6 @@ def virtual_memory():
except KeyError:
slab = 0
- used = total - free - cached - buffers
- if used < 0:
- # May be symptomatic of running within a LCX container where such
- # values will be dramatically distorted over those of the host.
- used = total - free
-
# - starting from 4.4.0 we match free's "available" column.
# Before 4.4.0 we calculated it as (free + buffers + cached)
# which matched htop.
@@ -510,6 +504,12 @@ def virtual_memory():
# 24fd2605c51fccc375ab0287cec33aa767f06718/proc/sysinfo.c#L764
avail = free
+ used = total - avail
+ if used < 0:
+ # May be symptomatic of running within a LCX container where such
+ # values will be dramatically distorted over those of the host.
+ used = total - free
+
percent = usage_percent((total - avail), total, round_=1)
# Warn about missing metrics which are set to 0.