Skip to content

Commit 40c5725

Browse files
committed
pythongh-96078: os.sched_yield release the GIL while calling sched_yield(2).
1 parent f8edc6f commit 40c5725

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
@@ -7075,8 +7075,13 @@ static PyObject *
70757075
os_sched_yield_impl(PyObject *module)
70767076
/*[clinic end generated code: output=902323500f222cac input=e54d6f98189391d4]*/
70777077
{
7078-
if (sched_yield())
7078+
int result;
7079+
Py_BEGIN_ALLOW_THREADS
7080+
result = sched_yield();
7081+
Py_END_ALLOW_THREADS
7082+
if (result < 0) {
70797083
return posix_error();
7084+
}
70807085
Py_RETURN_NONE;
70817086
}
70827087

0 commit comments

Comments
 (0)