Closed
Description
Feature or enhancement
#111903 added support for the @critical_section
directive to Argument Clinic. It currently assumes that the first argument is the one that should be locked. This is a good default, but there are at least a few cases where we want to lock a different argument.
For example, in the _weakref
module, we generally want to lock the object
argument, not the _weakref
module itself.
Let's add support for specifying the argument to lock. For example,
/*[clinic input]
@critical_section object
_weakref.getweakrefs
object: object
/
Return a list of all weak reference objects pointing to 'object'.
[clinic start generated code]*/
static PyObject *
_weakref_getweakrefs(PyObject *module, PyObject *object)
/*[clinic end generated code: output=25c7731d8e011824 input=00c6d0e5d3206693]*/