Skip to content

Commit 616fcad

Browse files
GH-103545: Add macOS specific constants for os.setpriority to os (#104606)
This adds a number of PRIO_DARWIN_* constants to the os module for use with os.setpriority. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
1 parent fd04bfe commit 616fcad

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

Doc/library/os.rst

+11
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,17 @@ process and user.
493493
.. versionadded:: 3.3
494494

495495

496+
.. data:: PRIO_DARWIN_THREAD
497+
PRIO_DARWIN_PROCESS
498+
PRIO_DARWIN_BG
499+
PRIO_DARWIN_NONUI
500+
501+
Parameters for the :func:`getpriority` and :func:`setpriority` functions.
502+
503+
.. availability:: macOS
504+
505+
.. versionadded:: 3.12
506+
496507
.. function:: getresuid()
497508

498509
Return a tuple (ruid, euid, suid) denoting the current process's
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``os.PRIO_DARWIN_THREAD``, ``os.PRIO_DARWIN_PROCESS``, ``os.PRIO_DARWIN_BG`` and ``os.PRIO_DARWIN_NONUI``. These can be used with ``os.setpriority`` to run the process at a lower priority and make use of the efficiency cores on Apple Silicon systems.

Modules/posixmodule.c

+12
Original file line numberDiff line numberDiff line change
@@ -15917,6 +15917,18 @@ all_ins(PyObject *m)
1591715917
#ifdef PRIO_USER
1591815918
if (PyModule_AddIntMacro(m, PRIO_USER)) return -1;
1591915919
#endif
15920+
#ifdef PRIO_DARWIN_THREAD
15921+
if (PyModule_AddIntMacro(m, PRIO_DARWIN_THREAD)) return -1;
15922+
#endif
15923+
#ifdef PRIO_DARWIN_PROCESS
15924+
if (PyModule_AddIntMacro(m, PRIO_DARWIN_PROCESS)) return -1;
15925+
#endif
15926+
#ifdef PRIO_DARWIN_BG
15927+
if (PyModule_AddIntMacro(m, PRIO_DARWIN_BG)) return -1;
15928+
#endif
15929+
#ifdef PRIO_DARWIN_NONUI
15930+
if (PyModule_AddIntMacro(m, PRIO_DARWIN_NONUI)) return -1;
15931+
#endif
1592015932
#ifdef O_CLOEXEC
1592115933
if (PyModule_AddIntMacro(m, O_CLOEXEC)) return -1;
1592215934
#endif

0 commit comments

Comments
 (0)