summaryrefslogtreecommitdiff
path: root/psutil/_pssunos.py
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-08-05 22:41:09 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2016-08-05 22:41:09 +0200
commit8f27cbb4c98e6398f93488c9c223e4c0cc2cb64d (patch)
treea26b82286af807d9eb84a5d03eac14ebca8c49ec /psutil/_pssunos.py
parent05defa04e74b94e01f64ab71425cd2bca29e1aeb (diff)
parent971a498db35dc6b18093d510aa2ab666615b6043 (diff)
downloadpsutil-8f27cbb4c98e6398f93488c9c223e4c0cc2cb64d.tar.gz
merge from master
Diffstat (limited to 'psutil/_pssunos.py')
-rw-r--r--psutil/_pssunos.py40
1 files changed, 38 insertions, 2 deletions
diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py
index 157dfddd..8eeb6d61 100644
--- a/psutil/_pssunos.py
+++ b/psutil/_pssunos.py
@@ -34,6 +34,7 @@ __extra__all__ = ["CONN_IDLE", "CONN_BOUND", "PROCFS_PATH"]
PAGE_SIZE = os.sysconf('SC_PAGE_SIZE')
AF_LINK = cext_posix.AF_LINK
+IS_64_BIT = sys.maxsize > 2**32
CONN_IDLE = "IDLE"
CONN_BOUND = "BOUND"
@@ -446,7 +447,20 @@ class Process(object):
@wrap_exceptions
def cpu_times(self):
- times = cext.proc_cpu_times(self.pid, self._procfs_path)
+ try:
+ times = cext.proc_cpu_times(self.pid, self._procfs_path)
+ except OSError as err:
+ if err.errno == errno.EOVERFLOW and not IS_64_BIT:
+ # We may get here if we attempt to query a 64bit process
+ # with a 32bit python.
+ # Error originates from read() and also tools like "cat"
+ # fail in the same way (!).
+ # Since there simply is no way to determine CPU times we
+ # return 0.0 as a fallback. See:
+ # https://github.com/giampaolo/psutil/issues/857
+ times = (0.0, 0.0, 0.0, 0.0)
+ else:
+ raise
return _common.pcputimes(*times)
@wrap_exceptions
@@ -510,6 +524,15 @@ class Process(object):
utime, stime = cext.query_process_thread(
self.pid, tid, procfs_path)
except EnvironmentError as err:
+ if err.errno == errno.EOVERFLOW and not IS_64_BIT:
+ # We may get here if we attempt to query a 64bit process
+ # with a 32bit python.
+ # Error originates from read() and also tools like "cat"
+ # fail in the same way (!).
+ # Since there simply is no way to determine CPU times we
+ # return 0.0 as a fallback. See:
+ # https://github.com/giampaolo/psutil/issues/857
+ continue
# ENOENT == thread gone in meantime
if err.errno == errno.ENOENT:
hit_enoent = True
@@ -609,7 +632,20 @@ class Process(object):
procfs_path = self._procfs_path
retlist = []
- rawlist = cext.proc_memory_maps(self.pid, procfs_path)
+ try:
+ rawlist = cext.proc_memory_maps(self.pid, procfs_path)
+ except OSError as err:
+ if err.errno == errno.EOVERFLOW and not IS_64_BIT:
+ # We may get here if we attempt to query a 64bit process
+ # with a 32bit python.
+ # Error originates from read() and also tools like "cat"
+ # fail in the same way (!).
+ # Since there simply is no way to determine CPU times we
+ # return 0.0 as a fallback. See:
+ # https://github.com/giampaolo/psutil/issues/857
+ return []
+ else:
+ raise
hit_enoent = False
for item in rawlist:
addr, addrsize, perm, name, rss, anon, locked = item