tuna: Fix setting a realtime scheduling policy
PATCH 1/1 tuna: Fix setting a realtime scheduling policy
According to the tuna documentation if a user specifies a real-time scheduling policy then the default priority is 1 if not specified.
Fix this in the gui by explicitly setting it to one in thread_set_attributes
There were also some incorrect debugging messages in thread_set_attributes because the affinity was sometimes treated as a list and sometimes treated as a set.
Fix this by converting the results of os.sched_getscheduler(pid) to a list
Signed-off-by John Kacur <[email protected]>
--- tuna/gui/util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tuna/gui/util.py +6 -2
@@ -68,6 +68,9 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus) curr_prio = int(pid_info["stat"]["rt_priority"]) if new_policy == os.SCHED_OTHER: new_prio = 0 + if new_policy == os.SCHED_FIFO or new_policy == os.SCHED_RR: + if not new_prio: + new_prio = 1 if curr_policy != new_policy or curr_prio != new_prio: param = os.sched_param(new_prio) try:
@@ -82,6 +85,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus) dialog.destroy() return False + curr_policy = os.sched_getscheduler(pid) if curr_policy != new_policy: print(_("couldn't change pid %(pid)d from %(cpol)s(%(cpri)d) to %(npol)s(%(npri)d)!") % \
@@ -93,7 +97,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus) changed = True try: - curr_affinity = os.sched_getaffinity(pid) + curr_affinity = list(os.sched_getaffinity(pid)) except OSError as err: if err.args[0] == errno.ESRCH: return False
@@ -116,7 +120,7 @@ def thread_set_attributes(pid_info, new_policy, new_prio, new_affinity, nr_cpus) return invalid_affinity() try: - curr_affinity = os.sched_getaffinity(pid) + curr_affinity = list(os.sched_getaffinity(pid)) except OSError as err: if err.args[0] == errno.ESRCH: return False
Signature · 1 line
2.51.0