Skip to content

Commit

Permalink
[Windows] Ignore disk I/O counters for drives that are not accessible
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Baeyens <[email protected]>
  • Loading branch information
mx-psi committed Aug 9, 2021
1 parent 5a76cfa commit 2b117e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -757,4 +757,4 @@ D: fix typos in documentation

N: Pablo Baeyens
W: https://github.com/mx-psi
I: 1598
I: 1598, 1974
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ XXXX-XX-XX
(patch by MaWe2019)
- 1598_: [Windows] psutil.disk_partitions() only returns mountpoints on drives
where it first finds one
- 1974_: [Windows] psutil.disk_io_counters() raises permission error.

5.8.0
=====
Expand Down
6 changes: 6 additions & 0 deletions psutil/arch/windows/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down

0 comments on commit 2b117e7

Please sign in to comment.