On Fri, 20 Mar 2020 19:24:22 +0100
Victor Stinner <vstin...@python.org> wrote:
> 
> One good example is Py_AddPendingCall(). The documentation says that
> it's safe to call it without holding the GIL. Except that right now,
> there is no reliable way to get the correct interpreter in this case
> (correct me if I'm wrong!).

Define what "the correct interpreter" is?

The only way to solve this conundrum IMHO is to add a
`Py_AddPendingCallEx(PyInterpreterState*)`.

> The function uses
> PyGILState_GetThisThreadState() which may return a Python thread state
> of the wrong interpreter :-( Again, the PyGILState API should be fixed
> to support subinterpreters.

Similarly, the only possible fix is to add a per-interpreter GILState
API (with a per-interpreter TLS variable under the hood).
The caller knows which interpreter context it wants to run Python code
in, so just let it pass that information to the GILState API.

The most annoying part is what to do with the legacy GILState API.

Regards

Antoine.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/QGKPIDP2AWODA7KBDJBVP5TIEFOGXTRD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to