Hi Mark, Le mar. 24 mars 2020 à 21:05, Mark Shannon <m...@hotpy.org> a écrit : > A native thread can only have one Python thread at a time, and must > switch using the PyThreadState_Swap() API.
Right. > So, I think the answer is yes. Nice. > Do you have a specific example or testcase? I don't know well the C API of subinterpreters. Usually, I look at _testcapi.run_in_subinterp(). This function is used by multiple unit tests checking the behavior of subinterpreters. -- My expectation is that the different ways to get the current Python thread state works as expected. PyThreadState *tstate = PyThreadState_Get(); /* PyThreadState_GET() is an alias to PyThreadState_Get() */ PyThreadState *tstate = _PyThreadState_GET(); I also expect that tstate->interp is the current interpreter. What is the behavior when the GIL is released? Is tstate equal to NULL when the GIL is released? -- The less clear part is the PyGILState API: PyThreadState *tstate = PyGILState_GetThisThreadState(); Does it return the current Pyhon thread state and is tstate->interp the current interpreter? Victor -- Night gathers, and now my watch begins. It shall not end until my death. _______________________________________________ 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/LTJKUVFL5YDUBGGIN7NMASB6SVQOTGNS/ Code of Conduct: http://python.org/psf/codeofconduct/