Skip to content

Commit e39b511

Browse files
fixes gh-96078: os.sched_yield release the GIL while calling sched_yield(2). (gh-97965)
(cherry picked from commit b9d2e81) Co-authored-by: Dong-hee Na <[email protected]>
1 parent d163d59 commit e39b511

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:func:`os.sched_yield` now release the GIL while calling sched_yield(2).
2+
Patch by Dong-hee Na.

Modules/posixmodule.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -7096,8 +7096,13 @@ static PyObject *
70967096
os_sched_yield_impl(PyObject *module)
70977097
/*[clinic end generated code: output=902323500f222cac input=e54d6f98189391d4]*/
70987098
{
7099-
if (sched_yield())
7099+
int result;
7100+
Py_BEGIN_ALLOW_THREADS
7101+
result = sched_yield();
7102+
Py_END_ALLOW_THREADS
7103+
if (result < 0) {
71007104
return posix_error();
7105+
}
71017106
Py_RETURN_NONE;
71027107
}
71037108

0 commit comments

Comments
 (0)