summaryrefslogtreecommitdiff
path: root/psutil/_psaix.py
diff options
context:
space:
mode:
authorwiggin15 <arnony@infinidat.com>2019-03-05 14:33:53 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2019-03-05 13:33:53 +0100
commit7a3037e7c0602f459cb7b4f0c0f887e7bb3a3d39 (patch)
tree8f1d24e4fbc275fbbcc829b5206d87dc7b36d4df /psutil/_psaix.py
parent888f138a45f42f1b9e12cfca2109307a32314d2c (diff)
downloadpsutil-7a3037e7c0602f459cb7b4f0c0f887e7bb3a3d39.tar.gz
Fix #1329: [AIX] disable some functions based on availability in libperfstat (#1349)
Diffstat (limited to 'psutil/_psaix.py')
-rw-r--r--psutil/_psaix.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/psutil/_psaix.py b/psutil/_psaix.py
index 4fc87827..ff086b90 100644
--- a/psutil/_psaix.py
+++ b/psutil/_psaix.py
@@ -39,6 +39,8 @@ __extra__all__ = ["PROCFS_PATH"]
HAS_THREADS = hasattr(cext, "proc_threads")
+HAS_NET_IO_COUNTERS = hasattr(cext, "net_io_counters")
+HAS_PROC_IO_COUNTERS = hasattr(cext, "proc_io_counters")
PAGE_SIZE = os.sysconf('SC_PAGE_SIZE')
AF_LINK = cext_posix.AF_LINK
@@ -211,7 +213,9 @@ def disk_partitions(all=False):
net_if_addrs = cext_posix.net_if_addrs
-net_io_counters = cext.net_io_counters
+
+if HAS_NET_IO_COUNTERS:
+ net_io_counters = cext.net_io_counters
def net_connections(kind, _pid=-1):
@@ -563,14 +567,15 @@ class Process(object):
def wait(self, timeout=None):
return _psposix.wait_pid(self.pid, timeout, self._name)
- @wrap_exceptions
- def io_counters(self):
- try:
- rc, wc, rb, wb = cext.proc_io_counters(self.pid)
- except OSError:
- # if process is terminated, proc_io_counters returns OSError
- # instead of NSP
- if not pid_exists(self.pid):
- raise NoSuchProcess(self.pid, self._name)
- raise
- return _common.pio(rc, wc, rb, wb)
+ if HAS_PROC_IO_COUNTERS:
+ @wrap_exceptions
+ def io_counters(self):
+ try:
+ rc, wc, rb, wb = cext.proc_io_counters(self.pid)
+ except OSError:
+ # if process is terminated, proc_io_counters returns OSError
+ # instead of NSP
+ if not pid_exists(self.pid):
+ raise NoSuchProcess(self.pid, self._name)
+ raise
+ return _common.pio(rc, wc, rb, wb)