I am working on the code below and when I am running in the main thread returns the correct printing. However, when I am running this function in a different thread (a QThread class) the code freeze in the PyRun_SimpleString function- printing and can not reach a break point below. Also no error is returned. I have noticed that this is happening when the sklearn function is imported. Could tou please help to run it correctly in a QThread class? Any help is highly appreciated! 
PyObject *moduleMain = PyImport_ImportModule("__main__");
PyRun_SimpleString(
    "def wrapper(arg1, arg2) :          \n"\
    "   import sklearn                  \n"\
    "   print(arg1, arg2)               \n"\
    );
PyObject *func = PyObject_GetAttrString(moduleMain, "wrapper");
PyObject *args = PyTuple_Pack(2, PyUnicode_FromString("hello1"), PyUnicode_FromString("hello2"));
Py_DECREF(moduleMain);
Py_DECREF(func);
Py_DECREF(args);
PS: Python 3.6.1 |Anaconda (64-bit) 4.4.0
EDIT:
PyEval_InitThreads();
PyEval_SaveThread();
PyGILState_STATE state = PyGILState_Ensure();
\\ code above
Py_DECREF(moduleMain);
Py_DECREF(func);
Py_DECREF(args);
PyGILState_Release(state);
