[Python-checkins] fixes gh-96078: os.sched_yield release the GIL while calling sched_yield(2). (gh-97965)

miss-islington webhook-mailer at python.org
Fri Oct 7 00:51:03 EDT 2022


https://github.com/python/cpython/commit/11945f2cf6ae4aeb8202f481e8881ec0fbfabe89
commit: 11945f2cf6ae4aeb8202f481e8881ec0fbfabe89
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-10-06T21:50:44-07:00
summary:

fixes gh-96078: os.sched_yield release the GIL while calling sched_yield(2). (gh-97965)

(cherry picked from commit b9d2e8171696514e9226164005f7bf24bf69e66d)

Co-authored-by: Dong-hee Na <donghee.na at python.org>

files:
A Misc/NEWS.d/next/Core and Builtins/2022-10-06-15-45-57.gh-issue-96078.fS-6mU.rst
M Modules/posixmodule.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-10-06-15-45-57.gh-issue-96078.fS-6mU.rst b/Misc/NEWS.d/next/Core and Builtins/2022-10-06-15-45-57.gh-issue-96078.fS-6mU.rst
new file mode 100644
index 000000000000..d1f949c6e13a
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-10-06-15-45-57.gh-issue-96078.fS-6mU.rst	
@@ -0,0 +1,2 @@
+:func:`os.sched_yield` now release the GIL while calling sched_yield(2).
+Patch by Dong-hee Na.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 0b8b41cb2ded..f602ae5c5892 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7028,8 +7028,13 @@ static PyObject *
 os_sched_yield_impl(PyObject *module)
 /*[clinic end generated code: output=902323500f222cac input=e54d6f98189391d4]*/
 {
-    if (sched_yield())
+    int result;
+    Py_BEGIN_ALLOW_THREADS
+    result = sched_yield();
+    Py_END_ALLOW_THREADS
+    if (result < 0) {
         return posix_error();
+    }
     Py_RETURN_NONE;
 }
 



More information about the Python-checkins mailing list