Skip to content

Commit c78de46

Browse files
committed
Fix test_posix failure on NetBSD buildbots: sched_setparam() and
sched_setscheduler() can fail with EINVAL if the process scheduling policy is neither SCHED_FIFO nor SCHED_RR.
1 parent 1ea12ff commit c78de46

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Lib/test/test_posix.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -930,17 +930,17 @@ def test_get_and_set_scheduler_and_param(self):
930930
self.assertRaises(OSError, posix.sched_getparam, -1)
931931
param = posix.sched_getparam(0)
932932
self.assertIsInstance(param.sched_priority, int)
933-
try:
934-
posix.sched_setscheduler(0, mine, param)
935-
except OSError as e:
936-
if e.errno != errno.EPERM:
937-
raise
938933

939-
# POSIX states that calling sched_setparam() on a process with a
940-
# scheduling policy other than SCHED_FIFO or SCHED_RR is
941-
# implementation-defined: FreeBSD returns EINVAL.
942-
if not sys.platform.startswith('freebsd'):
943-
posix.sched_setparam(0, param)
934+
# POSIX states that calling sched_setparam() or sched_setscheduler() on
935+
# a process with a scheduling policy other than SCHED_FIFO or SCHED_RR
936+
# is implementation-defined: NetBSD and FreeBSD can return EINVAL.
937+
if not sys.platform.startswith(('freebsd', 'netbsd')):
938+
try:
939+
posix.sched_setscheduler(0, mine, param)
940+
posix.sched_setparam(0, param)
941+
except OSError as e:
942+
if e.errno != errno.EPERM:
943+
raise
944944
self.assertRaises(OSError, posix.sched_setparam, -1, param)
945945

946946
self.assertRaises(OSError, posix.sched_setscheduler, -1, mine, param)

0 commit comments

Comments
 (0)