Hi, We are hosting the python interpreter(version 2.7.13) in a C application and calling a python function that has some calls to opencv-python functions (Representative code fragments are below). When the python function is called in the main interpreter, it works fine. However, when the it is called in a sub-interpreter, it hangs!
The C code is as follows: Py_Initialize(); PyEval_InitThreads(); #If RUN_IN_SUBINTERPRETER PyThreadState* threadState = Py_NewInterpreter(); PyThreadState *mainState = PyThreadState_Swap(threadState); #endif pName = PyString_FromString("abc_module"); pModule = PyImport_Import(pName); pDict = PyModule_GetDict(pModule); pFunc = PyDict_GetItemString(pDict, "abc_function"); pyList = GenerateArgList(); PyObject* pArgs = PyTuple_New(1); PyTuple_SetItem(pArgs, 0, pyList); pValue = PyObject_CallObject(pFunc, pArgs); The Python code is as follows: import sys import cv2 import numpy as np def abc_function(list): array = np.asarray(list) array = np.reshape(array, (100, 200, 4)).astype(np.uint8) array = abc_function_core(array) return array def abc_function_core(array): # array is passed to the below functions cv2.resize(....) cv2.cvtColor(...) cv2.equalizeHist(...) cv2.CascadeClassifier.detectMultiScale(...) cv2.rectangle(...) return array Is there any known incompatibility between the opencv-python package and sub-interpreters? We did find that there are some packages that are incompatible with sub-interpreters but we couldn't find any such information about opencv-python. My sincere apologies if this is not the appropriate group to be posting this question to. If that is the case, please let me know which group I should ask this question on. Thanks in advance for the help! Ashwin -- https://mail.python.org/mailman/listinfo/python-list