diff --git a/CREDITS b/CREDITS index e7d9fa782..28e654f2d 100644 --- a/CREDITS +++ b/CREDITS @@ -761,7 +761,7 @@ D: fix typos in documentation N: Pablo Baeyens W: https://github.com/mx-psi -I: 1598 +I: 1598, 1974 N: Xuehai Pan W: https://github.com/XuehaiPan diff --git a/HISTORY.rst b/HISTORY.rst index 9319ba1c5..ffbbe1b0b 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -50,6 +50,7 @@ XXXX-XX-XX by PetrPospisil) - 1991_: process_iter() can raise TypeError if invoked from multiple threads (not thread-safe). +- 1974_: [Windows] psutil.disk_io_counters() raises permission error. 5.8.0 ===== diff --git a/psutil/arch/windows/disk.c b/psutil/arch/windows/disk.c index 7c35e8124..99dafce83 100644 --- a/psutil/arch/windows/disk.c +++ b/psutil/arch/windows/disk.c @@ -140,6 +140,12 @@ psutil_disk_io_counters(PyObject *self, PyObject *args) { "ignore PhysicalDrive%i", devNum); goto next; } + else if (GetLastError() == ERROR_ACCESS_DENIED) { + // Ignore disks that we are not able to access. + psutil_debug("DeviceIoControl -> ERROR_ACCESS_DENIED; " + "ignore PhysicalDrive%i", devNum); + goto next; + } // XXX: it seems we should also catch ERROR_INVALID_PARAMETER: // https://sites.ualberta.ca/dept/aict/uts/software/openbsd/ // ports/4.1/i386/openafs/w-openafs-1.4.14-transarc/