This commit is contained in:
qianlifeng
2014-01-09 22:16:19 +08:00
parent 8d931e290a
commit 935d26f956
9 changed files with 38 additions and 46 deletions

View File

@@ -9,7 +9,6 @@ extern "C" __declspec(dllexport) void InitPythonEnv()
{
Py_Initialize();
PyEval_InitThreads();
PyEval_ReleaseLock();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>ǰִ<C7B0>У<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ͷ<EFBFBD>PyEval_InitThreads<64><73><EFBFBD>õ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳̿<DFB3><CCBF><EFBFBD><EFBFBD>޷<EFBFBD><DEB7><EFBFBD>ȡ<EFBFBD><C8A1>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
@@ -32,8 +31,8 @@ char* Exec(char* directory, char* file, char* method, char* para)
PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pClass, *pInstance;
char *error;
PyEval_ReleaseLock();
PyGILState_STATE gstate = PyGILState_Ensure();
// Build the name object
PyObject *path = PySys_GetObject("path");
PyList_Append(path, PyString_FromString(directory));
@@ -91,14 +90,13 @@ char* Exec(char* directory, char* file, char* method, char* para)
//PyErr_Clear();
PyGILState_Release(gstate);
return str_ret;
}
extern "C" __declspec(dllexport) char* ExecPython(char* directory, char* file, char* method, char* para)
{
//PyEval_ReleaseLock();
char* s = Exec(directory,file,method,para);
PyGILState_Ensure();
return s;
//auto future = std::async(Exec,directory,file,method,para);
//return future.get();