Multithreading with Python and C api
A correct order of steps to perform what you are trying to do is: In the main thread: Initialize Python using Py_Initialize*. Initialize Python threading support using PyEval_InitThreads(). Start the C++ thread. At this point, the main thread still holds the GIL. In a C++ thread: Acquire the GIL using PyGILState_Ensure(). Create a new Python … Read more