From 64ea2080bd081ec2e26649949b5a309bee009b6e Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Tue, 11 Apr 2023 20:22:01 -0700 Subject: [PATCH] Rename psutil_get_swappercent to psutil_swap_percent Signed-off-by: Daniel Widdis --- psutil/_psutil_windows.c | 2 +- psutil/arch/windows/wmi.c | 3 ++- psutil/arch/windows/wmi.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index a5bdafd37a..0ce4e8ffe4 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -1599,7 +1599,7 @@ PsutilMethods[] = { {"disk_usage", psutil_disk_usage, METH_VARARGS}, {"getloadavg", (PyCFunction)psutil_get_loadavg, METH_VARARGS}, {"getpagesize", psutil_getpagesize, METH_VARARGS}, - {"getpercentswap", (PyCFunction)psutil_get_percentswap, METH_VARARGS}, + {"getpercentswap", (PyCFunction)psutil_swap_percent, METH_VARARGS}, {"init_loadavg_counter", (PyCFunction)psutil_init_loadavg_counter, METH_VARARGS}, {"net_connections", psutil_net_connections, METH_VARARGS}, {"net_if_addrs", psutil_net_if_addrs, METH_VARARGS}, diff --git a/psutil/arch/windows/wmi.c b/psutil/arch/windows/wmi.c index f4a248163e..1ed890f73c 100644 --- a/psutil/arch/windows/wmi.c +++ b/psutil/arch/windows/wmi.c @@ -131,7 +131,7 @@ psutil_get_loadavg(PyObject *self, PyObject *args) { * the system. */ PyObject * -psutil_get_percentswap(PyObject *self, PyObject *args) { +psutil_swap_percent(PyObject *self, PyObject *args) { WCHAR *szCounterPath = L"\\Paging File(_Total)\\% Usage"; PDH_STATUS s; HQUERY hQuery; @@ -146,6 +146,7 @@ psutil_get_percentswap(PyObject *self, PyObject *args) { s = PdhAddEnglishCounterW(hQuery, szCounterPath, 0, &hCounter); if (s != ERROR_SUCCESS) { + PdhCloseQuery(hQuery); PyErr_Format( PyExc_RuntimeError, "PdhAddEnglishCounterW failed. Performance counters may be disabled." diff --git a/psutil/arch/windows/wmi.h b/psutil/arch/windows/wmi.h index c93411077e..00461a20d8 100644 --- a/psutil/arch/windows/wmi.h +++ b/psutil/arch/windows/wmi.h @@ -8,4 +8,4 @@ PyObject* psutil_init_loadavg_counter(); PyObject* psutil_get_loadavg(); -PyObject* psutil_get_percentswap(); +PyObject* psutil_swap_percent();