def test_num_handles(self):
import ctypes
import ctypes.wintypes
PROCESS_QUERY_INFORMATION = 0x400
handle = ctypes.windll.kernel32.OpenProcess(
PROCESS_QUERY_INFORMATION, 0, os.getpid())
self.addCleanup(ctypes.windll.kernel32.CloseHandle, handle)
hndcnt = ctypes.wintypes.DWORD()
ctypes.windll.kernel32.GetProcessHandleCount(
handle, ctypes.byref(hndcnt))
sys_value = hndcnt.value
psutil_value = psutil.Process().num_handles()
ctypes.windll.kernel32.CloseHandle(handle)
self.assertEqual(psutil_value, sys_value + 1)
评论列表
文章目录