STINNER Victor <vstin...@python.org> added the comment:
Extract of test2.C: --- // in main thread Py_Initialize(); PyEval_InitThreads(); PyEval_SaveThread(); // creating a new sub-interpreter, in my real app, this would be created // in a sub-thread. PyInterpreterState* const mainInterpreterState = PyInterpreterState_New(); PyThreadState* const taskState = PyThreadState_New(mainInterpreterState); PyEval_AcquireThread(taskState); PyThreadState * const sub_interp = Py_NewInterpreter(); PyThreadState_Swap( taskState ); PyEval_ReleaseThread( taskState ); --- IMO this code is not supported. It creates 3 interpreters: * Py_Initialize(): good * PyInterpreterState_New(): partially initialized * Py_NewInterpreter(): created from the partially initialized interpreter IMHO PyInterpreterState_New() should never be used outside Python internals. Only Py_NewInterpreter() should be used. At least, this code now fails since PyInterpreterState_New() configuration (interp->config) is empty/uninitizalized, and so _PySys_InitMain() fails. Moreover, the example uses PyGILState C API which isn't compatible with subinterpreters yet :-( ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue26693> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com