Add setpriority / getpriority to os module.

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

Christian Heimes <lists@cheimes.de> wrote:
I don't think there's likely to be much controversy about putting these in. -- R. David Murray http://www.bitdance.com

Alexandre Vassalotti <alexandre@peadrop.com> wrote:
'resource' is Unix specific, but Josiah indicates Windows equivalents to set/getpriority are possible. In that case it seems like it belongs in posix/os since it can eventually be made cross-platform. -- R. David Murray http://www.bitdance.com

Christian Heimes <lists@cheimes.de> wrote:
I don't think there's likely to be much controversy about putting these in. -- R. David Murray http://www.bitdance.com

Alexandre Vassalotti <alexandre@peadrop.com> wrote:
'resource' is Unix specific, but Josiah indicates Windows equivalents to set/getpriority are possible. In that case it seems like it belongs in posix/os since it can eventually be made cross-platform. -- R. David Murray http://www.bitdance.com
participants (4)
-
Alexandre Vassalotti
-
Christian Heimes
-
Josiah Carlson
-
R. David Murray