test_windows.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:FancyWord 作者: EastonLee 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号