Variable 'parms' should be 'parm'. Fix typo.
Signed-off-by: Leah Leshchinsky lleshchi@redhat.com
diff --git a/tuna/tuna.py b/tuna/tuna.py index 8fb42121e2e4..126990339985 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -561,7 +561,7 @@ def threads_set_priority(tids, parm, affect_children=False): try: (policy, rtprio) = get_policy_and_rtprio(parm) except ValueError: - print("tuna: " + _(""%s" is unsupported priority value!") % parms[0]) + print("tuna: " + _(""%s" is an unsupported priority value!") % parm[0]) return
for tid in tids:
In tuna-cmd.py, if a thread list is passed along with the '--priority' flag, tuna.get_policy_and_rtprio() is called twice, first directly, and then again by tuna.threads_set_priority(). The expectation is that tuna.threads_set_priority will handle exceptions raised by tuna.get_policy_and_rtprio(). This results in a failure to handle exceptions that are raised by the initial direct call to tuna.get_policy_and_rtprio().
Handle exceptions that may be raised during direct calls to get_policy_and_rtprio in tuna-cmd.py.
Signed-off-by: Leah Leshchinsky lleshchi@redhat.com
diff --git a/tuna-cmd.py b/tuna-cmd.py index cf117ec046ff..2b6e91bd0104 100755 --- a/tuna-cmd.py +++ b/tuna-cmd.py @@ -601,7 +601,11 @@ def main(): tuna.include_cpus(cpu_list, get_nr_cpus()) elif o in ("-p", "--priority"): # Save policy and rtprio for future Actions (e.g. --run). - (policy, rtprio) = tuna.get_policy_and_rtprio(a) + try: + (policy, rtprio) = tuna.get_policy_and_rtprio(a) + except ValueError: + print("tuna: " + _(""%s" is an unsupported priority value!") % a) + sys.exit(2) if not thread_list: # For backward compatibility p_waiting_action = True
On Wed, 2 Feb 2022, Leah Leshchinsky wrote:
In tuna-cmd.py, if a thread list is passed along with the '--priority' flag, tuna.get_policy_and_rtprio() is called twice, first directly, and then again by tuna.threads_set_priority(). The expectation is that tuna.threads_set_priority will handle exceptions raised by tuna.get_policy_and_rtprio(). This results in a failure to handle exceptions that are raised by the initial direct call to tuna.get_policy_and_rtprio().
Handle exceptions that may be raised during direct calls to get_policy_and_rtprio in tuna-cmd.py.
Signed-off-by: Leah Leshchinsky lleshchi@redhat.com
diff --git a/tuna-cmd.py b/tuna-cmd.py index cf117ec046ff..2b6e91bd0104 100755 --- a/tuna-cmd.py +++ b/tuna-cmd.py @@ -601,7 +601,11 @@ def main(): tuna.include_cpus(cpu_list, get_nr_cpus()) elif o in ("-p", "--priority"): # Save policy and rtprio for future Actions (e.g. --run).
(policy, rtprio) = tuna.get_policy_and_rtprio(a)
try:
(policy, rtprio) = tuna.get_policy_and_rtprio(a)
except ValueError:
print("tuna: " + _("\"%s\" is an unsupported priority value!") % a)
sys.exit(2) if not thread_list: # For backward compatibility p_waiting_action = True
--
Signed-off-by: John Kacur jkacur@redhat.com
The implementation of the error handling block in tuna.get_policy_and_rtprio() caused the exceptions raised by tuna_sched.Policy to be consumed by the finally block. When an invalid policy is passed via the '--priority' flag, this consumption of the exception causes tuna to fail silently.
Remove the finally block in tuna.get_policy_and_rtprio().
Signed-off-by: Leah Leshchinsky lleshchi@redhat.com
diff --git a/tuna/tuna.py b/tuna/tuna.py index 126990339985..31707c9cb69c 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -520,8 +520,8 @@ def get_policy_and_rtprio(parm): rtprio = int(parms[1]) elif cp.is_rt(): rtprio = 1 - finally: - return(policy, rtprio) + + return (policy, rtprio)
def thread_filtered(tid, cpus_filtered, show_kthreads, show_uthreads): if cpus_filtered:
The implementation of the error handling block in tuna.get_policy_and_rtprio() caused the exceptions raised by tuna_sched.Policy to be consumed by the finally block. When an invalid policy is passed via the '--priority' flag, this consumption of the exception causes tuna to fail silently.
Remove the finally block in tuna.get_policy_and_rtprio().
Signed-off-by: Leah Leshchinsky lleshchi@redhat.com
diff --git a/tuna/tuna.py b/tuna/tuna.py index 126990339985..31707c9cb69c 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -520,8 +520,8 @@ def get_policy_and_rtprio(parm): rtprio = int(parms[1]) elif cp.is_rt(): rtprio = 1 - finally: - return(policy, rtprio) + + return (policy, rtprio)
def thread_filtered(tid, cpus_filtered, show_kthreads, show_uthreads): if cpus_filtered:
On Wed, 2 Feb 2022, Leah Leshchinsky wrote:
The implementation of the error handling block in tuna.get_policy_and_rtprio() caused the exceptions raised by tuna_sched.Policy to be consumed by the finally block. When an invalid policy is passed via the '--priority' flag, this consumption of the exception causes tuna to fail silently.
Remove the finally block in tuna.get_policy_and_rtprio().
Signed-off-by: Leah Leshchinsky lleshchi@redhat.com
diff --git a/tuna/tuna.py b/tuna/tuna.py index 126990339985..31707c9cb69c 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -520,8 +520,8 @@ def get_policy_and_rtprio(parm): rtprio = int(parms[1]) elif cp.is_rt(): rtprio = 1
- finally:
return(policy, rtprio)
- return (policy, rtprio)
def thread_filtered(tid, cpus_filtered, show_kthreads, show_uthreads): if cpus_filtered: --
Signed-off-by: John Kacur jkacur@redhat.com
On Wed, 2 Feb 2022, Leah Leshchinsky wrote:
Variable 'parms' should be 'parm'. Fix typo.
Signed-off-by: Leah Leshchinsky lleshchi@redhat.com
diff --git a/tuna/tuna.py b/tuna/tuna.py index 8fb42121e2e4..126990339985 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -561,7 +561,7 @@ def threads_set_priority(tids, parm, affect_children=False): try: (policy, rtprio) = get_policy_and_rtprio(parm) except ValueError:
print("tuna: " + _("\"%s\" is unsupported priority value!") % parms[0])
print("tuna: " + _("\"%s\" is an unsupported priority value!") % parm[0]) return
for tid in tids:
--
Signed-off-by: John Kacur jkacur@redhat.com
tuna-devel@lists.fedorahosted.org