From bcaf1e729a6fee0d4b00941813c7a85d0718d701 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Tue, 22 Jan 2019 16:16:39 +0000 Subject: [PATCH] Bug 1518762 - Avoid error in psutil.disk_io_counters in resourcemonitor. r=ahal, a=jcristau DONTBUILD Imports https://github.com/giampaolo/psutil/commit/8f99f3782663959062ee868bbfdbc336307a3a4d to fix a bug with Linux kernel 4.18+, https://github.com/giampaolo/psutil/issues/1354 (to be included in a future release of psutil, version 5.5.0) Differential Revision: https://phabricator.services.mozilla.com/D16028 [jcristau: re-applying this change which was accidentally reverted in https://hg.mozilla.org/releases/mozilla-release/rev/e2030db2e502] --- third_party/python/psutil/psutil/_pslinux.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/third_party/python/psutil/psutil/_pslinux.py b/third_party/python/psutil/psutil/_pslinux.py index b57adb34e5d55..5d8b7ea1af6db 100644 --- a/third_party/python/psutil/psutil/_pslinux.py +++ b/third_party/python/psutil/psutil/_pslinux.py @@ -1051,6 +1051,8 @@ def get_partitions(): # ...unless (Linux 2.6) the line refers to a partition instead # of a disk, in which case the line has less fields (7): # "3 1 hda1 8 8 8 8" + # 4.18+ has 4 fields added: + # "3 0 hda 8 8 8 8 8 8 8 8 8 8 8 0 0 0 0" # See: # https://www.kernel.org/doc/Documentation/iostats.txt # https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats @@ -1062,7 +1064,7 @@ def get_partitions(): reads = int(fields[2]) (reads_merged, rbytes, rtime, writes, writes_merged, wbytes, wtime, _, busy_time, _) = map(int, fields[4:14]) - elif fields_len == 14: + elif fields_len == 14 or fields_len == 18: # Linux 2.6+, line referring to a disk name = fields[2] (reads, reads_merged, rbytes, rtime, writes, writes_merged,