I've found this question about GIL released by modules: Does who releases GIL in Python?
I was looking for the os.sched_yield()
implementation and I can't see the GIL release macro or function:
/*[clinic input]
os.sched_yield
Voluntarily relinquish the CPU.
[clinic start generated code]*/
static PyObject *
os_sched_yield_impl(PyObject *module)
/*[clinic end generated code: output=902323500f222cac input=e54d6f98189391d4]*/
{
if (sched_yield())
return posix_error();
Py_RETURN_NONE;
}
I think it would be ridiculous not to release the GIL while calling sched_yield()
. Is it released anywhere else?
Unfortunately, it was an issue - GIL hasn't been released, but should be. The bug is there since the function was implemented, 11 years ago. More info on the issue: https://github.com/python/cpython/issues/96078