-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os.getpriority() and os.setpriority() #54993
Comments
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(): |
Forgot to attach the patch. |
Patch looks good, just one thing: In setpriority(), it should be possible to use the Py_RETURN_NONE; macro instead of INCREFing manually. |
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 |
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. |
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. |
Committed in r88608 including Py_RETURN_NONE and Py_BEGIN/END_ALLOW_THREADS changes. |
Misc/NEWS updated in r88609. |
====================================================================== 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' |
On Sat, Feb 26, 2011 at 12:11:10AM +0000, Antoine Pitrou wrote:
That was one 'S' too many. Should be errno.EACCES |
Indeed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: