msg124751 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) *  |
Date: 2010-12-28 01:46 |
After having implemented a similar thing in psutil ( http://code.google.com/p/psutil/issues/detail?id=142 ) I decided to contribute a patch for Python which exposes getpriority() and setpriority() POSIX calls in the os module. They can be used to get/set process niceness/priority in a fashion similar to os.nice() but extended to *all* processes instead of just os.getpid(): http://linux.die.net/man/2/setpriority |
|
|
msg124752 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) *  |
Date: 2010-12-28 01:47 |
Forgot to attach the patch. |
|
|
msg124763 - (view) |
Author: Ross Lagerwall (rosslagerwall)  |
Date: 2010-12-28 05:36 |
Patch looks good, just one thing: In setpriority(), it should be possible to use the Py_RETURN_NONE; macro instead of INCREFing manually. |
|
|
msg124778 - (view) |
Author: Georg Brandl (georg.brandl) *  |
Date: 2010-12-28 10:18 |
Looks good. Would there be a point in making any of the parameters optional? |
|
|
msg124780 - (view) |
Author: Martin v. Löwis (loewis) *  |
Date: 2010-12-28 10:32 |
> Looks good. Would there be a point in making any of the parameters optional? No. The API should look exactly as it does on the system level. Anybody calling these functions should know how call them. |
|
|
msg125887 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) *  |
Date: 2011-01-10 09:44 |
Question: should Py_BEGIN/END_ALLOW_THREADS be used around getpriority() and setpriority() calls? It's still not clear to me when to use them exactly. |
|
|
msg125908 - (view) |
Author: Martin v. Löwis (loewis) *  |
Date: 2011-01-10 17:55 |
You should use begin/end allow threads when the system call might block. To get an indication, trace through the kernel code of some system; my guess is that these are typically non-blocking (i.e. return immediately) - but I might be wrong. |
|
|
msg129426 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) *  |
Date: 2011-02-25 20:58 |
Committed in r88608 including Py_RETURN_NONE and Py_BEGIN/END_ALLOW_THREADS changes. |
|
|
msg129427 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) *  |
Date: 2011-02-25 21:00 |
Misc/NEWS updated in r88609. |
|
|
msg129474 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2011-02-26 00:11 |
====================================================================== ERROR: test_set_get_priority (test.test_os.ProgramPriorityTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/buildbot/buildarea/3.x.ochtman-gentoo-amd64/build/Lib/test/test_os.py", line 1283, in test_set_get_priority os.setpriority(os.PRIO_PROCESS, os.getpid(), base) OSError: [Errno 13] Permission denied During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/buildbot/buildarea/3.x.ochtman-gentoo-amd64/build/Lib/test/test_os.py", line 1285, in test_set_get_priority if err.errno != errno.EACCESS: AttributeError: 'module' object has no attribute 'EACCESS' |
|
|
msg129501 - (view) |
Author: Senthil Kumaran (orsenthil) *  |
Date: 2011-02-26 06:34 |
On Sat, Feb 26, 2011 at 12:11:10AM +0000, Antoine Pitrou wrote: > if err.errno != errno.EACCESS: > AttributeError: 'module' object has no attribute 'EACCESS' That was one 'S' too many. Should be errno.EACCES Looks like Antoine has fixed it in r88627. |
|
|
msg129504 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2011-02-26 06:40 |
Indeed. |
|
|