diff options
author | Leah Leshchinsky <lleshchi@redhat.com> | 2022-08-04 09:39:11 -0400 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2022-08-23 10:27:52 -0400 |
commit | 9dd8c3e889fe632405561cc8476ed42659a99e2e (patch) | |
tree | b52ca9cefd17a13c9b23eff643e37b1da17a7c70 | |
parent | eba1333c50f8a5eebb12b523c30faffac33681b3 (diff) | |
download | tuna-9dd8c3e889fe632405561cc8476ed42659a99e2e.tar.gz |
tuna: Move get_policy_and_rtprio call to parser level
Due to the implementation of the parser for the priority action,
the valid policy and rtprio input can be checked at the parser level.
Call get_policy_and_rtprio on `priority` and `run --priority` commands
at argparse level.
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
-rwxr-xr-x | tuna-cmd.py | 2 | ||||
-rwxr-xr-x | tuna/tuna.py | 7 |
2 files changed, 3 insertions, 6 deletions
diff --git a/tuna-cmd.py b/tuna-cmd.py index f49cce4..5549120 100755 --- a/tuna-cmd.py +++ b/tuna-cmd.py @@ -102,7 +102,7 @@ def gen_parser(): "filename": dict(metavar='FILENAME', type=str, help="Save kthreads sched tunables to this file"), "profilename": dict(type=str, help="Apply changes described in this file"), "run_command": dict(metavar='COMMAND', type=str, help="fork a new process and run the \"COMMAND\""), - "priority": dict(type=str, help="policy/priority help"), + "priority": dict(type=tuna.get_policy_and_rtprio, help="policy/priority help"), } MODS = { diff --git a/tuna/tuna.py b/tuna/tuna.py index 8650f11..30a5a57 100755 --- a/tuna/tuna.py +++ b/tuna/tuna.py @@ -558,11 +558,8 @@ def thread_set_priority(tid, policy, rtprio): os.sched_setscheduler(tid, policy, param) def threads_set_priority(tids, parm, affect_children=False): - try: - (policy, rtprio) = get_policy_and_rtprio(parm) - except ValueError: - print("tuna: " + _("\"%s\" is an unsupported priority value!") % parm[0]) - return + + (policy, rtprio) = parm for tid in tids: try: |