@@ -1084,8 +1084,9 @@ interpreter (created automatically by :c:func:`Py_Initialize`). Python
10841084supports the creation of additional interpreters (using
10851085:c:func:`Py_NewInterpreter`), but mixing multiple interpreters and the
10861086``PyGILState_*`` API is unsupported. This is because :c:func:`PyGILState_Ensure`
1087- and similar functions almost always acquire the :term:`GIL` of the main interpreter
1088- in threads created by subinterpreters, which can lead to data races or deadlocks.
1087+ and similar functions default to :term:`attaching <attached thread state>` a
1088+ :term:`thread state` for the main interpreter, meaning that the thread can't safely
1089+ interact with the calling subinterpreter.
10891090
10901091Supporting subinterpreters in non-Python threads
10911092------------------------------------------------
@@ -1094,11 +1095,9 @@ If you would like to support subinterpreters with non-Python created threads, yo
10941095must use the ``PyThreadState_*`` API instead of the traditional ``PyGILState_*``
10951096API.
10961097
1097- In particular, you must store the exact interpreter state from the calling
1098- function and pass it to :c:func:`PyThreadState_New` to ensure that the thread
1099- acquires the :term:`GIL` of the subinterpreter instead of the main interpreter.
1100- In turn, this means that the return value of :c:func:`PyInterpreterState_Get`
1101- should be stored alongside any information passed to the thread.::
1098+ In particular, you must store the interpreter state from the calling
1099+ function and pass it to :c:func:`PyThreadState_New`, which will ensure that
1100+ the :term:`thread state` is targeting the correct interpreter.::
11021101
11031102 /* The return value of PyInterpreterState_Get() from the
11041103 function that created this thread. */
0 commit comments