diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2019-04-05 02:16:40 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2019-04-05 02:16:40 +0200 |
commit | 84448be84278b1701ea1d4163cd46c6b959bf1be (patch) | |
tree | ae7f92f6e4e91c1218669e634abfb4ce5c5968de /psutil/_pslinux.py | |
parent | 16128f7298f490d11368dad316fa8e53348ed52d (diff) | |
parent | e471e7cbad9e2d84f9fb114da86df78755836852 (diff) | |
download | psutil-84448be84278b1701ea1d4163cd46c6b959bf1be.tar.gz |
merge from masterosx-ionice
Diffstat (limited to 'psutil/_pslinux.py')
-rw-r--r-- | psutil/_pslinux.py | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index ecba4139..6c58cf2c 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -41,7 +41,6 @@ from ._common import supports_ipv6 from ._common import usage_percent from ._compat import b from ._compat import basestring -from ._compat import long from ._compat import PY3 if sys.version_info >= (3, 4): @@ -1987,35 +1986,12 @@ class Process(object): @wrap_exceptions def ionice_set(self, ioclass, value): - if value is not None: - if not PY3 and not isinstance(value, (int, long)): - msg = "value argument is not an integer (gor %r)" % value - raise TypeError(msg) - if not 0 <= value <= 7: - raise ValueError( - "value argument range expected is between 0 and 7") - - if ioclass in (IOPRIO_CLASS_NONE, None): - if value: - msg = "can't specify value with IOPRIO_CLASS_NONE " \ - "(got %r)" % value - raise ValueError(msg) - ioclass = IOPRIO_CLASS_NONE + if value is None: value = 0 - elif ioclass == IOPRIO_CLASS_IDLE: - if value: - msg = "can't specify value with IOPRIO_CLASS_IDLE " \ - "(got %r)" % value - raise ValueError(msg) - value = 0 - elif ioclass in (IOPRIO_CLASS_RT, IOPRIO_CLASS_BE): - if value is None: - # TODO: add comment explaining why this is 4 (?) - value = 4 - else: - # otherwise we would get OSError(EVINAL) - raise ValueError("invalid ioclass argument %r" % ioclass) - + if value and ioclass == IOPRIO_CLASS_IDLE: + raise ValueError("IOPRIO_CLASS_IDLE accepts no value") + if value < 0 or value > 7: + raise ValueError("value not in 0-7 range") return cext.proc_ioprio_set(self.pid, ioclass, value) if HAS_PRLIMIT: |