Issue 10784: os.getpriority() and os.setpriority() (original) (raw)

Created on 2010-12-28 01:46 by giampaolo.rodola, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
getsetpriority.patch giampaolo.rodola,2010-12-28 01:47
Messages (12)
msg124751 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) 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) * (Python committer) Date: 2010-12-28 01:47
Forgot to attach the patch.
msg124763 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) Date: 2011-02-25 21:00
Misc/NEWS updated in r88609.
msg129474 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) 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) * (Python committer) 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) * (Python committer) Date: 2011-02-26 06:40
Indeed.
History
Date User Action Args
2022-04-11 14:57:10 admin set github: 54993
2011-02-26 06:40:26 pitrou set status: open -> closednosy:loewis, georg.brandl, orsenthil, pitrou, giampaolo.rodola, christian.heimes, rosslagerwallmessages: +
2011-02-26 06:34:39 orsenthil set nosy: + orsenthilmessages: +
2011-02-26 00:11:08 pitrou set status: closed -> opennosy:loewis, georg.brandl, pitrou, giampaolo.rodola, christian.heimes, rosslagerwallmessages: +
2011-02-25 21:00:27 giampaolo.rodola set nosy:loewis, georg.brandl, pitrou, giampaolo.rodola, christian.heimes, rosslagerwallmessages: +
2011-02-25 20:58:43 giampaolo.rodola set status: open -> closedmessages: + resolution: fixednosy:loewis, georg.brandl, pitrou, giampaolo.rodola, christian.heimes, rosslagerwall
2011-01-10 20:02:45 pitrou set nosy:loewis, georg.brandl, pitrou, giampaolo.rodola, christian.heimes, rosslagerwallstage: patch review
2011-01-10 17:55:27 loewis set nosy:loewis, georg.brandl, pitrou, giampaolo.rodola, christian.heimes, rosslagerwallmessages: +
2011-01-10 09:44:30 giampaolo.rodola set nosy:loewis, georg.brandl, pitrou, giampaolo.rodola, christian.heimes, rosslagerwallmessages: +
2010-12-28 10:32:04 loewis set nosy:loewis, georg.brandl, pitrou, giampaolo.rodola, christian.heimes, rosslagerwallmessages: +
2010-12-28 10🔞26 georg.brandl set nosy: + georg.brandlmessages: +
2010-12-28 05:36:19 rosslagerwall set nosy: + rosslagerwallmessages: + components: + Extension Modulestype: enhancement
2010-12-28 02:04:50 giampaolo.rodola set nosy: + christian.heimes
2010-12-28 01:47:08 giampaolo.rodola set files: + getsetpriority.patchnosy:loewis, pitrou, giampaolo.rodolamessages: +
2010-12-28 01:46:49 giampaolo.rodola create