From d9c7e3cbb86e004279fa93238873611a251c15c0 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sun, 28 Feb 2016 13:18:01 +0100 Subject: update ideas --- IDEAS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IDEAS b/IDEAS index 18c40633..2b27c714 100644 --- a/IDEAS +++ b/IDEAS @@ -17,6 +17,8 @@ PLATFORMS FEATURES ======== +- #782: (UNIX) process num of signals received. + - (UNIX) process root (different from xwd) - (Linux) locked files via /proc/locks: -- cgit v1.2.1 From 65c89727ffaea201123ecfbaa45c42cb280cc4c0 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 29 Feb 2016 12:44:23 +0100 Subject: #780: attempt to fix compilation issues on OSX --- psutil/_psutil_osx.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index f76ca0e6..8c3d81e4 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -581,11 +581,14 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { mach_msg_type_number_t info_count = VM_REGION_TOP_INFO_COUNT; kern_return_t kr; vm_size_t page_size; + mach_vm_address_t addr = MACH_VM_MIN_ADDRESS + mach_port_t task = MACH_PORT_NULL; + vm_region_top_info_data_t info; + mach_port_t object_name; if (! PyArg_ParseTuple(args, "l", &pid)) return NULL; - mach_port_t task = MACH_PORT_NULL; err = task_for_pid(mach_task_self(), pid, &task); if (err != KERN_SUCCESS) { psutil_raise_ad_or_nsp(pid); @@ -600,10 +603,7 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { // Roughly based on libtop_update_vm_regions in // http://www.opensource.apple.com/source/top/top-100.1.2/libtop.c - for (mach_vm_address_t addr = MACH_VM_MIN_ADDRESS; ; addr += size) { - vm_region_top_info_data_t info; - mach_port_t object_name; - + for (addr; ; addr += size) { kr = mach_vm_region( task, &addr, &size, VM_REGION_TOP_INFO, (vm_region_info_t)&info, &info_count, &object_name); @@ -612,7 +612,8 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { break; } else if (kr != KERN_SUCCESS) { - return false; + PyErr_Format(PyExc_RuntimeError, "mach_vm_region() failed"); + return NULL; } if (psutil_in_shared_region(addr, cpu_type) && -- cgit v1.2.1 From 39c84ff9f46e1056bfff568c1bb1369182017472 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 29 Feb 2016 12:53:28 +0100 Subject: #780: attempt to fix compilation issues on OSX --- psutil/_psutil_osx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index 8c3d81e4..c02a38bd 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -603,7 +603,7 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { // Roughly based on libtop_update_vm_regions in // http://www.opensource.apple.com/source/top/top-100.1.2/libtop.c - for (addr; ; addr += size) { + for (addr = 0; ; addr += size) { kr = mach_vm_region( task, &addr, &size, VM_REGION_TOP_INFO, (vm_region_info_t)&info, &info_count, &object_name); -- cgit v1.2.1 From 5d7b17a6a209c2f9d80d9cf3ae53a843b1d3ce89 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 29 Feb 2016 13:00:51 +0100 Subject: #780: attempt to fix compilation issues on OSX --- HISTORY.rst | 1 + psutil/_psutil_osx.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 5ba233b8..72e5d124 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -14,6 +14,7 @@ Bug tracker at https://github.com/giampaolo/psutil/issues provides it. - #776: [Linux] Process.cpu_affinity() may erroneously raise NoSuchProcess. (patch by wxwright) +- #780: [OSX] psutil does not compile with some gcc versions. 4.0.0 - 2016-02-17 diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index c02a38bd..e9a898ac 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -581,7 +581,7 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { mach_msg_type_number_t info_count = VM_REGION_TOP_INFO_COUNT; kern_return_t kr; vm_size_t page_size; - mach_vm_address_t addr = MACH_VM_MIN_ADDRESS + mach_vm_address_t addr = MACH_VM_MIN_ADDRESS; mach_port_t task = MACH_PORT_NULL; vm_region_top_info_data_t info; mach_port_t object_name; -- cgit v1.2.1 From 6ae5f36d43027787b513a69f45408c248c0154ed Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 29 Feb 2016 13:39:31 +0100 Subject: travis: try to run pypy --- .travis.yml | 1 + HISTORY.rst | 2 ++ psutil/_pslinux.py | 10 +++++----- psutil/tests/__init__.py | 1 + psutil/tests/test_linux.py | 18 +++++++++++------- psutil/tests/test_process.py | 6 ++++++ 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 03f19132..17206c58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ matrix: - python: 3.3 - python: 3.4 - python: 3.5 + - "pypy" # XXX - commented because OSX builds are deadly slow # - language: generic # os: osx diff --git a/HISTORY.rst b/HISTORY.rst index 72e5d124..8393e278 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -37,6 +37,8 @@ Bug tracker at https://github.com/giampaolo/psutil/issues **Bug fixes** +- #685: [Linux] virtual_memory() provides wrong results on systems with a lot + of physical memory. - #704: [Solaris] psutil does not compile on Solaris sparc. - #734: on Python 3 invalid UTF-8 data is not correctly handled for process name(), cwd(), exe(), cmdline() and open_files() methods resulting in diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 324ff5cb..47084ede 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -180,13 +180,13 @@ def readlink(path): def file_flags_to_mode(flags): - md = {os.O_RDONLY: 'r', os.O_WRONLY: 'w', os.O_RDWR: 'w+'} - m = md[flags & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)] + modes_map = {os.O_RDONLY: 'r', os.O_WRONLY: 'w', os.O_RDWR: 'w+'} + mode = modes_map[flags & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)] if flags & os.O_APPEND: - m = m.replace('w', 'a', 1) - m = m.replace('w+', 'r+') + mode = mode.replace('w', 'a', 1) + mode = mode.replace('w+', 'r+') # possible values: r, w, a, r+, a+ - return m + return mode def get_sector_size(): diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 7ff5133f..a3a8f1ba 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -82,6 +82,7 @@ TESTFN = os.path.join(os.getcwd(), "$testfile") TESTFN_UNICODE = TESTFN + "ƒőő" TESTFILE_PREFIX = 'psutil-test-suite-' TOX = os.getenv('TOX') or '' in ('1', 'true') +PYPY = '__pypy__' in sys.builtin_module_names if not PY3: try: TESTFN_UNICODE = unicode(TESTFN_UNICODE, sys.getfilesystemencoding()) diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index a9545991..67da1b54 100644 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -33,6 +33,7 @@ from psutil.tests import call_until from psutil.tests import get_kernel_version from psutil.tests import importlib from psutil.tests import MEMORY_TOLERANCE +from psutil.tests import PYPY from psutil.tests import pyrun from psutil.tests import reap_children from psutil.tests import retry_before_failing @@ -764,13 +765,16 @@ class TestProcess(unittest.TestCase): time.sleep(.1) mem = p.memory_full_info() maps = p.memory_maps(grouped=False) - self.assertEqual( - mem.uss, sum([x.private_dirty + x.private_clean for x in maps])) - self.assertEqual( - mem.pss, sum([x.pss for x in maps])) - self.assertEqual( - mem.swap, sum([x.swap for x in maps])) - + self.assertAlmostEqual( + mem.uss, sum([x.private_dirty + x.private_clean for x in maps]), + delta=4096) + self.assertAlmostEqual( + mem.pss, sum([x.pss for x in maps]), delta=4096) + self.assertAlmostEqual( + mem.swap, sum([x.swap for x in maps]), delta=4096) + + # On PYPY file descriptors are not closed fast enough. + @unittest.skipIf(PYPY, "skipped on PYPY") def test_open_files_mode(self): def get_test_file(): p = psutil.Process() diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index c556caf0..5ad606da 100644 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -65,6 +65,7 @@ from psutil.tests import get_test_subprocess from psutil.tests import get_winver from psutil.tests import GLOBAL_TIMEOUT from psutil.tests import pyrun +from psutil.tests import PYPY from psutil.tests import PYTHON from psutil.tests import reap_children from psutil.tests import retry_before_failing @@ -423,6 +424,11 @@ class TestProcess(unittest.TestCase): self.assertGreaterEqual(value, 0) if name in dir(resource): self.assertEqual(value, getattr(resource, name)) + # XXX - On PyPy RLIMIT_INFINITY returned by + # resource.getrlimit() is reported as a very big long + # number instead of -1. It looks like a bug with PyPy. + if PYPY: + continue self.assertEqual(p.rlimit(value), resource.getrlimit(value)) else: ret = p.rlimit(value) -- cgit v1.2.1 From 170680a8e50d2af1f031499ebb55b0ce7c223c31 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 1 Mar 2016 15:34:00 +0100 Subject: update doc --- docs/index.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index b6cf4d91..91067d67 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -266,16 +266,22 @@ Disks .. function:: disk_io_counters(perdisk=False) Return system-wide disk I/O statistics as a namedtuple including the - following fields. + following fields: + - **read_count**: number of reads - **write_count**: number of writes - **read_bytes**: number of bytes read - **write_bytes**: number of bytes written - - **read_time**: (all except NetBSD and OpenBSD) time spent reading from disk (in milliseconds) - - **write_time**: (all except NetBSD and OpenBSD) time spent writing to disk (in milliseconds) - - **busy_time**: (Linux, FreeBSD) time spent doing actual I/Os (in milliseconds) - - **read_merged_count** (Linux): number of merged reads (see `iostat doc `__) - - **write_merged_count** (Linux): number of merged writes (see `iostats doc `__) + - **read_time**: (all except NetBSD and OpenBSD) time spent reading from + disk (in milliseconds) + - **write_time**: (all except NetBSD and OpenBSD) time spent writing to disk + (in milliseconds) + - **busy_time**: (Linux, FreeBSD) time spent doing actual I/Os (in + milliseconds) + - **read_merged_count** (Linux): number of merged reads + (see `iostat doc `__) + - **write_merged_count** (Linux): number of merged writes + (see `iostats doc `__) If *perdisk* is ``True`` return the same information for every physical disk installed on the system as a dictionary with partition names as the keys and -- cgit v1.2.1