]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fixes gh-96078: os.sched_yield release the GIL while calling sched_yield(2). (gh...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 7 Oct 2022 04:50:44 +0000 (21:50 -0700)
committerGitHub <noreply@github.com>
Fri, 7 Oct 2022 04:50:44 +0000 (21:50 -0700)
(cherry picked from commit b9d2e8171696514e9226164005f7bf24bf69e66d)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
Misc/NEWS.d/next/Core and Builtins/2022-10-06-15-45-57.gh-issue-96078.fS-6mU.rst [new file with mode: 0644]
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 (file)
index 0000000..d1f949c
--- /dev/null
@@ -0,0 +1,2 @@
+:func:`os.sched_yield` now release the GIL while calling sched_yield(2).
+Patch by Dong-hee Na.
index 0b8b41cb2ded7cb9a29c59b46fd3f473b5e3224f..f602ae5c589267ce27f1eca0e456b6a8d8ae935e 100644 (file)
@@ -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;
 }