You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PEP 703 in large part relies on replacing the GIL with fine grained per-object locks. The primary way to acquire and release these locks is through the critical section API (#111569). It would be helpful if argument clinic could auto generate the API calls in the binding code when specified.
For example, the bufferedio.c will require per-object locking around most calls for thread-safety in --disable-gil builds.
As an example, the _io._Buffered.close function is written as:
/*[clinic end generated code: output=7280b7b42033be0c input=d20b83d1ddd7d805]*/
We might add a @critical_section directive to designate that argument clinic should generate Py_BEGIN_CRITICAL_SECTION() and Py_END_CRITICAL_SECTION() in the binding code before calling _io__Buffered_close_impl.
Feature or enhancement
PEP 703 in large part relies on replacing the GIL with fine grained per-object locks. The primary way to acquire and release these locks is through the critical section API (#111569). It would be helpful if argument clinic could auto generate the API calls in the binding code when specified.
For example, the
bufferedio.cwill require per-object locking around most calls for thread-safety in--disable-gilbuilds.As an example, the
_io._Buffered.closefunction is written as:cpython/Modules/_io/bufferedio.c
Lines 523 to 529 in 6f09f69
We might add a
@critical_sectiondirective to designate that argument clinic should generatePy_BEGIN_CRITICAL_SECTION()andPy_END_CRITICAL_SECTION()in the binding code before calling_io__Buffered_close_impl.The generated binding code in
bufferedio.c.hwould then look like:Note that
Py_BEGIN/END_CRITICAL_SECTION()are no-ops in the default build.Linked PRs
@critical_sectiondirective to Argument Clinic. #111904