2

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;
}

(from https://github.com/python/cpython/blob/cfaa79aac088284c1eeacddc19ddebe06b55dcf7/Modules/posixmodule.c#L7060)

I think it would be ridiculous not to release the GIL while calling sched_yield(). Is it released anywhere else?

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
DeZee
  • 95
  • 6

1 Answers1

0

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

DeZee
  • 95
  • 6