[Python-ideas] Add setpriority / getpriority to os module.

Christian Heimes lists at cheimes.de
Wed Apr 8 03:12:20 CEST 2009


Hello,

I would like to add straight forward wrapper for the setpriority and
getpriority functions to posixmodule.c for the os module. The functions
allow to retrieve and modify the niceness of a process. They are in
particular useful for multiprocessing to implement low priority
processes. The functions are well known as 'nice' or 'renice' commands.

The two functions and the constants PRIO_PROCESS, PRIO_PGRP, PRIO_USER,
PRIO_MIN and PRIO_MAX should be available on most POSIX operating
systems. A patch would come with autoconf tests for the feature.

A while ago somebody suggested a more high level wrapper for the
scheduling niceness that abstracts the niceness level. Windows (through
pywin32) has a different set of values. Such a wrapper is out of scope
for my proposal. Once the os module has the POSIX wrappers it's going to
be easy to create a pure Python abstraction.

I've also some code laying around to modify the IO priority and CPU
affinity on Linux. However the code is more complex and won't work on
other Unix operating systems. If somebody can implement the feature for
*BSD I'm willing to give it a try.

Christian




More information about the Python-ideas mailing list