I think the closest to a standard we get here is from POSIX (IEEE 1003). The actual specification there does leave the range to the implementation, but notes:
If value+{NZERO} is less than the system’s lowest supported nice
value, setpriority( ) shall set the nice value to the lowest supported
value; if value+{NZERO} is greater than the system’s highest supported
nice value, setpriority( ) shall set the nice value to the highest
supported value.
Thus, if you just want the highest niceness, you could pass it INT_MAX
, but that value is not easily found in Python. NZERO
does provide the bounds, but is likewise hard to find (it's defined in limits.h
).
However, Python's os.nice
doesn't behave like setpriority
- it increases the process niceness, and also returns the resulting niceness. So if all you want to do is set the highest niceness, you could just run a while loop until os.nice(N)
returns the same value twice, given N is any positive value that does fit in ctypes.c_int
(any integer from 1 to 32767 is guaranteed to fit).