Note that I'm constrained to use Python 2.6. I have a Python 2.6 application that uses a C++ multi-threaded API library built with boost-python. My use-case was simply to execute a Python function callback from a C++ boost thread but despite the many different attempts and researching all the available online resources I haven't found any way that works. All the proposed solutions revolve around a different combination of the functions: Py_Initialize*
, PyEval_InitThreads
, PyGILState_Ensure
, PyGILState_Release
but after trying all possible combinations nothing works in practice e.g.
- Embedding Python in multi-threaded C++ applications with code here
- PyEval_InitThreads in Python 3: How/when to call it? (the saga continues ad nauseum)
Therefore, this question: how can I start and run a Python thread from C++? I basically want to: create it, run it with a Python target function object and forget about it.
Is that possible?