using python interpreters per thread in C++ program

sturlamolden sturlamolden at yahoo.no
Mon Sep 7 07:42:27 CEST 2009


On 7 Sep, 07:17, grbgooglefan <ganeshbo... at gmail.com> wrote:


> What is best way to embed python in multi-threaded C++ application?

Did you remeber to acquire the GIL? The GIL is global to the process
(hence the name).

void foobar(void)
{
    PyGILState_STATE state = PyGILState_Ensure();

    /* Safe to use Python C API here */

    PyGILState_Release(state);
}


S.M.











> Please guide.




More information about the Python-list mailing list