summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2018-12-10 15:04:17 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2018-12-10 15:04:17 +0100
commit314ab75295cbcdc6d8a12f89a08d702795593eca (patch)
treef2118cd0f8861e6c20b490813c13666b71c056d9
parent790292d3902a51800117e9343be918ec1ddecbde (diff)
downloadpsutil-314ab75295cbcdc6d8a12f89a08d702795593eca.tar.gz
fix #1357: do not expose Process' memory_maps() and io_counters() methods if not supported by the kernel
-rw-r--r--HISTORY.rst2
-rw-r--r--psutil/_pslinux.py15
2 files changed, 6 insertions, 11 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index 263a381f..59bf9f67 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -14,6 +14,8 @@ XXXX-XX-XX
**Bug fixes**
- 1354_: [Linux] disk_io_counters() fails on Linux kernel 4.18+.
+- 1357_: [Linux] Process' memory_maps() and io_counters() method are no longer
+ exposed if not supported by the kernel.
- 1368_: [Windows] fix psutil.Process().ionice(...) mismatch. (patch by
EccoTheFlintstone)
- 1370_: [Windows] improper usage of CloseHandle() may lead to override the
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index b775d39a..51cb2009 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -1642,6 +1642,7 @@ class Process(object):
except KeyError:
return None
+ # May not be available on old kernels.
if os.path.exists('/proc/%s/io' % os.getpid()):
@wrap_exceptions
def io_counters(self):
@@ -1673,10 +1674,6 @@ class Process(object):
except KeyError as err:
raise ValueError("%r field was not found in %s; found fields "
"are %r" % (err[0], fname, fields))
- else:
- def io_counters(self):
- raise NotImplementedError("couldn't find /proc/%s/io (kernel "
- "too old?)" % self.pid)
@wrap_exceptions
def cpu_times(self):
@@ -1767,6 +1764,9 @@ class Process(object):
"""Return process's mapped memory regions as a list of named
tuples. Fields are explained in 'man proc'; here is an updated
(Apr 2012) version: http://goo.gl/fmebo
+
+ /proc/{PID}/smaps does not exist on kernels < 2.6.14 or if
+ CONFIG_MMU kernel configuration option is not enabled.
"""
def get_blocks(lines, current_block):
data = {}
@@ -1827,13 +1827,6 @@ class Process(object):
))
return ls
- else: # pragma: no cover
- def memory_maps(self):
- raise NotImplementedError(
- "/proc/%s/smaps does not exist on kernels < 2.6.14 or "
- "if CONFIG_MMU kernel configuration option is not "
- "enabled." % self.pid)
-
@wrap_exceptions
def cwd(self):
try: