|
|
e9a79c |
From 0c70baee8d3af97a130bc745adda85e530bd30b0 Mon Sep 17 00:00:00 2001
|
|
|
e9a79c |
From: John Kacur <jkacur@redhat.com>
|
|
|
e9a79c |
Date: Tue, 4 Dec 2018 01:36:19 +0100
|
|
|
e9a79c |
Subject: [PATCH 2/2] tuna: Use exception args attribute for python3
|
|
|
e9a79c |
|
|
|
e9a79c |
In python3 exceptions are not interable, so use the args attribute
|
|
|
e9a79c |
|
|
|
e9a79c |
Signed-off-by: John Kacur <jkacur@redhat.com>
|
|
|
e9a79c |
---
|
|
|
e9a79c |
tuna-cmd.py | 4 ++--
|
|
|
e9a79c |
tuna/gui/util.py | 4 ++--
|
|
|
e9a79c |
tuna/tuna.py | 46 +++++++++++++++++++++++-----------------------
|
|
|
e9a79c |
3 files changed, 27 insertions(+), 27 deletions(-)
|
|
|
e9a79c |
|
|
|
e9a79c |
diff --git a/tuna-cmd.py b/tuna-cmd.py
|
|
|
e9a79c |
index 8068695ae6df..e4182231d80f 100755
|
|
|
e9a79c |
--- a/tuna-cmd.py
|
|
|
e9a79c |
+++ b/tuna-cmd.py
|
|
|
e9a79c |
@@ -182,7 +182,7 @@ def ps_show_thread(pid, affect_children, ps,
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
affinity = format_affinity(schedutils.get_affinity(pid))
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
return
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
|
|
|
e9a79c |
@@ -264,7 +264,7 @@ def ps_show(ps, affect_children, thread_list, cpu_list,
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
affinity = schedutils.get_affinity(pid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
if cpu_list and not set(cpu_list).intersection(set(affinity)):
|
|
|
e9a79c |
diff --git a/tuna/gui/util.py b/tuna/gui/util.py
|
|
|
e9a79c |
index 73eceae23ab7..9e30ed92bd4c 100755
|
|
|
e9a79c |
--- a/tuna/gui/util.py
|
|
|
e9a79c |
+++ b/tuna/gui/util.py
|
|
|
e9a79c |
@@ -86,7 +86,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus)
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
curr_affinity = schedutils.get_affinity(pid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == 3:
|
|
|
e9a79c |
+ if e.args[0] == 3:
|
|
|
e9a79c |
return False
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
|
|
|
e9a79c |
@@ -109,7 +109,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus)
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
curr_affinity = schedutils.get_affinity(pid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # (3, 'No such process') old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == 3:
|
|
|
e9a79c |
+ if e.args[0] == 3:
|
|
|
e9a79c |
return False
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
|
|
|
e9a79c |
diff --git a/tuna/tuna.py b/tuna/tuna.py
|
|
|
e9a79c |
index 9f9267863871..4b1a77bcfa9f 100755
|
|
|
e9a79c |
--- a/tuna/tuna.py
|
|
|
e9a79c |
+++ b/tuna/tuna.py
|
|
|
e9a79c |
@@ -193,7 +193,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
curr_affinity = schedutils.get_affinity(pid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
curr_affinity = None
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
@@ -202,7 +202,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
|
|
|
e9a79c |
schedutils.set_affinity(pid, new_affinity)
|
|
|
e9a79c |
curr_affinity = schedutils.get_affinity(pid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
curr_affinity == None
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
@@ -231,7 +231,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
curr_affinity = schedutils.get_affinity(tid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
if set(curr_affinity) != set(new_affinity):
|
|
|
e9a79c |
@@ -239,7 +239,7 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
|
|
|
e9a79c |
schedutils.set_affinity(tid, new_affinity)
|
|
|
e9a79c |
curr_affinity = schedutils.get_affinity(tid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
if set(curr_affinity) == set(new_affinity):
|
|
|
e9a79c |
@@ -251,10 +251,10 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
|
|
|
e9a79c |
(_("could not change %(pid)d affinity to %(new_affinity)s") % \
|
|
|
e9a79c |
{'pid':pid, 'new_affinity':new_affinity}))
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
# process died
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
- elif e[0] == errno.EINVAL: # unmovable thread)
|
|
|
e9a79c |
+ elif e.args[0] == errno.EINVAL: # unmovable thread)
|
|
|
e9a79c |
print("thread %(pid)d cannot be moved as requested" %{'pid':pid}, file=stderr)
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
@@ -301,7 +301,7 @@ def move_irqs_to_cpu(cpus, irq_list, spread = False):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
schedutils.set_affinity(pid, new_affinity)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
unprocessed.append(i)
|
|
|
e9a79c |
changed -= 1
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
@@ -336,9 +336,9 @@ def isolate_cpus(cpus, nr_cpus):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
affinity = schedutils.get_affinity(pid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
- elif e[0] == errno.EINVAL:
|
|
|
e9a79c |
+ elif e.args[0] == errno.EINVAL:
|
|
|
e9a79c |
print("Function:", fname, ",", e.strerror, file=sys.stderr)
|
|
|
e9a79c |
sys.exit(2)
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
@@ -348,9 +348,9 @@ def isolate_cpus(cpus, nr_cpus):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
schedutils.set_affinity(pid, affinity)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
- elif e[0] == errno.EINVAL:
|
|
|
e9a79c |
+ elif e.args[0] == errno.EINVAL:
|
|
|
e9a79c |
print("Function:", fname, ",", e.strerror, file=sys.stderr)
|
|
|
e9a79c |
sys.exit(2)
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
@@ -364,9 +364,9 @@ def isolate_cpus(cpus, nr_cpus):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
affinity = schedutils.get_affinity(tid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
- elif e[0] == errno.EINVAL:
|
|
|
e9a79c |
+ elif e.args[0] == errno.EINVAL:
|
|
|
e9a79c |
print("Function:", fname, ",", e.strerror, file=sys.stderr)
|
|
|
e9a79c |
sys.exit(2)
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
@@ -376,9 +376,9 @@ def isolate_cpus(cpus, nr_cpus):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
schedutils.set_affinity(tid, affinity)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
- elif e[0] == errno.EINVAL:
|
|
|
e9a79c |
+ elif e.args[0] == errno.EINVAL:
|
|
|
e9a79c |
print("Function:", fname, ",", e.strerror, file=sys.stderr)
|
|
|
e9a79c |
sys.exit(2)
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
@@ -416,7 +416,7 @@ def include_cpus(cpus, nr_cpus):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
affinity = schedutils.get_affinity(pid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
if set(affinity).intersection(set(cpus)) != set(cpus):
|
|
|
e9a79c |
@@ -425,7 +425,7 @@ def include_cpus(cpus, nr_cpus):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
schedutils.set_affinity(pid, affinity)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
|
|
|
e9a79c |
@@ -438,7 +438,7 @@ def include_cpus(cpus, nr_cpus):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
affinity = schedutils.get_affinity(tid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
if set(affinity).intersection(set(cpus)) != set(cpus):
|
|
|
e9a79c |
@@ -447,7 +447,7 @@ def include_cpus(cpus, nr_cpus):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
schedutils.set_affinity(tid, affinity)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
|
|
|
e9a79c |
@@ -515,7 +515,7 @@ def thread_filtered(tid, cpus_filtered, show_kthreads, show_uthreads):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
affinity = schedutils.get_affinity(tid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
return False
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
|
|
|
e9a79c |
@@ -554,7 +554,7 @@ def threads_set_priority(tids, parm, affect_children = False):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
thread_set_priority(tid, policy, rtprio)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
if affect_children:
|
|
|
e9a79c |
@@ -563,7 +563,7 @@ def threads_set_priority(tids, parm, affect_children = False):
|
|
|
e9a79c |
try:
|
|
|
e9a79c |
thread_set_priority(child, policy, rtprio)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
|
|
|
e9a79c |
@@ -594,7 +594,7 @@ def get_kthread_sched_tunings(proc = None):
|
|
|
e9a79c |
policy = schedutils.get_scheduler(pid)
|
|
|
e9a79c |
affinity = schedutils.get_affinity(pid)
|
|
|
e9a79c |
except (SystemError, OSError) as e: # old python-schedutils incorrectly raised SystemError
|
|
|
e9a79c |
- if e[0] == errno.ESRCH:
|
|
|
e9a79c |
+ if e.args[0] == errno.ESRCH:
|
|
|
e9a79c |
continue
|
|
|
e9a79c |
raise e
|
|
|
e9a79c |
percpu = iskthread(pid) and \
|
|
|
e9a79c |
--
|
|
|
e9a79c |
2.19.2
|
|
|
e9a79c |
|