diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2015-11-09 11:53:10 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2015-11-09 11:53:10 +0100 |
commit | 4cb337336736e982d14b2d56c0a4411b747a7d6e (patch) | |
tree | ba8c2675873772bbba5ce9968e1978cc442edbcc | |
parent | de979004d8e4eb314a7564ead62afec95adf7780 (diff) | |
parent | e079f3c8feeeec70c1ea32491cf39721c1c82d15 (diff) | |
download | psutil-4cb337336736e982d14b2d56c0a4411b747a7d6e.tar.gz |
Merge branch 'master' into landryb-openbsd
-rw-r--r-- | psutil/_psbsd.py | 8 | ||||
-rw-r--r-- | psutil/_psutil_bsd.c | 9 | ||||
-rw-r--r-- | psutil/_psutil_osx.c | 6 | ||||
-rw-r--r-- | test/test_psutil.py | 9 |
4 files changed, 21 insertions, 11 deletions
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py index c864f206..60fcdd48 100644 --- a/psutil/_psbsd.py +++ b/psutil/_psbsd.py @@ -30,13 +30,13 @@ FREEBSD = sys.platform.startswith("freebsd") OPENBSD = sys.platform.startswith("openbsd") PROC_STATUSES = { - cext.SSTOP: _common.STATUS_STOPPED, - cext.SSLEEP: _common.STATUS_SLEEPING, - cext.SRUN: _common.STATUS_RUNNING, cext.SIDL: _common.STATUS_IDLE, + cext.SRUN: _common.STATUS_RUNNING, + cext.SSLEEP: _common.STATUS_SLEEPING, + cext.SSTOP: _common.STATUS_STOPPED, + cext.SZOMB: _common.STATUS_ZOMBIE, cext.SWAIT: _common.STATUS_WAITING, cext.SLOCK: _common.STATUS_LOCKED, - cext.SZOMB: _common.STATUS_ZOMBIE, } TCP_STATUSES = { diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c index 37459a23..69d473da 100644 --- a/psutil/_psutil_bsd.c +++ b/psutil/_psutil_bsd.c @@ -2233,13 +2233,14 @@ void init_psutil_bsd(void) PyModule_AddIntConstant(module, "version", PSUTIL_VERSION); // process status constants - PyModule_AddIntConstant(module, "SSTOP", SSTOP); - PyModule_AddIntConstant(module, "SSLEEP", SSLEEP); - PyModule_AddIntConstant(module, "SRUN", SRUN); PyModule_AddIntConstant(module, "SIDL", SIDL); + PyModule_AddIntConstant(module, "SRUN", SRUN); + PyModule_AddIntConstant(module, "SSLEEP", SSLEEP); + PyModule_AddIntConstant(module, "SSTOP", SSTOP); + PyModule_AddIntConstant(module, "SZOMB", SZOMB); PyModule_AddIntConstant(module, "SWAIT", SWAIT); PyModule_AddIntConstant(module, "SLOCK", SLOCK); - PyModule_AddIntConstant(module, "SZOMB", SZOMB); + // connection status constants PyModule_AddIntConstant(module, "TCPS_CLOSED", TCPS_CLOSED); PyModule_AddIntConstant(module, "TCPS_CLOSING", TCPS_CLOSING); diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index fa0ef29c..2830ee38 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -171,8 +171,10 @@ psutil_proc_exe(PyObject *self, PyObject *args) { if (! PyArg_ParseTuple(args, "l", &pid)) return NULL; ret = proc_pidpath(pid, &buf, sizeof(buf)); - if (ret == 0) - return psutil_raise_ad_or_nsp(pid); + if (ret == 0) { + psutil_raise_ad_or_nsp(pid); + return NULL; + } return Py_BuildValue("s", buf); } diff --git a/test/test_psutil.py b/test/test_psutil.py index 14478ff2..0e4fe2da 100644 --- a/test/test_psutil.py +++ b/test/test_psutil.py @@ -1231,7 +1231,7 @@ class TestProcess(unittest.TestCase): with mock.patch('psutil.os.kill', side_effect=OSError(errno.EPERM, "")) as fun: with self.assertRaises(psutil.AccessDenied): - p.send_signal(sig) + psutil.Process().send_signal(sig) assert fun.called def test_wait(self): @@ -1625,6 +1625,13 @@ class TestProcess(unittest.TestCase): if thread._running: thread.stop() + def test_threads_2(self): + p = psutil.Process() + self.assertAlmostEqual(p.cpu_times().user, + p.threads()[0].user_time, delta=0.1) + self.assertAlmostEqual(p.cpu_times().system, + p.threads()[0].system_time, delta=0.1) + def test_memory_info(self): p = psutil.Process() |