sys-apps/dool: fix KeyError in dool_disk_avgqu.py

Closes: https://bugs.gentoo.org/784704
Signed-off-by: Florian Schmaus <flo@geekplace.eu>
This commit is contained in:
Florian Schmaus
2021-05-03 19:38:32 +02:00
parent 82b1c42abe
commit e9d4c62de5
3 changed files with 51 additions and 0 deletions

View File

@@ -31,6 +31,10 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE}"
RDEPEND="${PYTHON_DEPS}"
DEPEND="${RDEPEND}"
PATCHES=(
"${FILESDIR}/0001-Key-for-key-in-dool_disk_avgqu.py-to-avoid-KeyError.patch"
)
src_compile() {
:
}

View File

@@ -31,6 +31,10 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE}"
RDEPEND="${PYTHON_DEPS}"
DEPEND="${RDEPEND}"
PATCHES=(
"${FILESDIR}/0001-Key-for-key-in-dool_disk_avgqu.py-to-avoid-KeyError.patch"
)
src_compile() {
:
}

View File

@@ -0,0 +1,43 @@
From 67b58a3e453d6a7b9c225c1f210e20fe2605908a Mon Sep 17 00:00:00 2001
From: Florian Schmaus <flo@geekplace.eu>
Date: Mon, 3 May 2021 19:34:41 +0200
Subject: [PATCH] Key for key in dool_disk_avgqu.py to avoid KeyError
Running "make test" may fail with:
Traceback (most recent call last):
File "./dool", line 2899, in <module>
main()
File "./dool", line 2751, in main
scheduler.run()
File "/usr/lib/python3.7/sched.py", line 151, in run
action(*argument, **kwargs)
File "./dool", line 2847, in perform
o.extract()
File "<string>", line 63, in extract
KeyError: 'rq_ticks'
make: *** [Makefile:38: test] Error 1
See https://bugs.gentoo.org/784704
---
plugins/dool_disk_avgqu.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/plugins/dool_disk_avgqu.py b/plugins/dool_disk_avgqu.py
index 5da8d4666d5c..bc421a82028a 100644
--- a/plugins/dool_disk_avgqu.py
+++ b/plugins/dool_disk_avgqu.py
@@ -60,6 +60,10 @@ class dstat_plugin(dstat):
)
for name in self.vars:
+ # Avoid KeyError: 'rq_ticks'
+ # See https://bugs.gentoo.org/784704
+ if 'rq_ticks' not in self.set1[name] or 'rq_ticks' not in self.set2[name]:
+ continue
self.val[name] = ( ( self.set2[name]['rq_ticks'] - self.set1[name]['rq_ticks'] ) * 1.0 / elapsed / 1000, )
if step == op.delay:
--
2.30.2