Python 3.3+Linuxosfunction
os.sched_getscheduler
os — scheduler (sched)
Return a process's scheduling policy (e.g. SCHED_OTHER/SCHED_FIFO).
Syntax
os.sched_getscheduler(...)
Ordinary processes run under SCHED_OTHER, where priority is set via nice. The real-time policies SCHED_FIFO and SCHED_RR have their own priorities from 1 to 99 and preempt every ordinary process. Zero instead of a PID means the current process.
Examples
import os
policy = os.sched_getscheduler(0); print(policy) # → 0 — числовой код текущей политики планирования
print(policy == os.SCHED_OTHER) # → True — обычный процесс идёт по политике по умолчанию
print(os.SCHED_OTHER, os.SCHED_FIFO, os.SCHED_RR) # → ? только Unix: 0 1 2 — коды политик в Linux
print(os.sched_getscheduler(os.getppid()) == os.SCHED_OTHER) # → ? только Unix: True — родитель тоже под обычной политикой
os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(10)) # → ? только Unix: PermissionError без прав root; с root процесс уходит в реальное время
See also
Open in the full glossarydocs.python.orgReport an inaccuracy