summaryrefslogtreecommitdiff
path: root/psutil/_pslinux.py
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2018-10-16 22:18:33 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2018-10-16 22:18:33 +0200
commit6db8d2e41dc67621eae9d8eeab3c39fef7e2ddf4 (patch)
treedb98aaae072a2b73a5c2d4ac76858d8346beaefc /psutil/_pslinux.py
parent8b465260638cde5370808e23eb9ace608141393a (diff)
downloadpsutil-6db8d2e41dc67621eae9d8eeab3c39fef7e2ddf4.tar.gz
refactor hasattr() checks as global constants
Diffstat (limited to 'psutil/_pslinux.py')
-rw-r--r--psutil/_pslinux.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index 1520261c..236934fc 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -73,6 +73,7 @@ __extra__all__ = [
POWER_SUPPLY_PATH = "/sys/class/power_supply"
HAS_SMAPS = os.path.exists('/proc/%s/smaps' % os.getpid())
HAS_PRLIMIT = hasattr(cext, "linux_prlimit")
+HAS_PROC_IO_PRIORITY = hasattr(cext, "proc_ioprio_get")
_DEFAULT = object()
# RLIMIT_* constants, not guaranteed to be present on all kernels
@@ -1928,7 +1929,7 @@ class Process(object):
raise
# only starting from kernel 2.6.13
- if hasattr(cext, "proc_ioprio_get"):
+ if HAS_PROC_IO_PRIORITY:
@wrap_exceptions
def ionice_get(self):
@@ -1971,6 +1972,7 @@ class Process(object):
return cext.proc_ioprio_set(self.pid, ioclass, value)
if HAS_PRLIMIT:
+
@wrap_exceptions
def rlimit(self, resource, limits=None):
# If pid is 0 prlimit() applies to the calling process and