This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients martin.panter, pitrou, skydoom, vstinner, zach.ware
Date 2019-10-23.00:06:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571789209.38.0.860972979256.issue26693@roundup.psfhosted.org>
In-reply-to
Content
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 :-(
History
Date User Action Args
2019-10-23 00:06:49vstinnersetrecipients: + vstinner, pitrou, martin.panter, zach.ware, skydoom
2019-10-23 00:06:49vstinnersetmessageid: <1571789209.38.0.860972979256.issue26693@roundup.psfhosted.org>
2019-10-23 00:06:49vstinnerlinkissue26693 messages
2019-10-23 00:06:49vstinnercreate