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 Oct 19, 2021
1 parent d1cce5c commit 5b8e9c2
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 @@ -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
Expand Down
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=====
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 5b8e9c2

Please sign in to comment.