From 3639d8ce8629a512d434cf7e70428f47508e8dbc Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 9 Jul 2014 15:06:08 +0400 Subject: [PATCH] Fix problem with the python initialization on windows. --- src/PyInterp/PyInterp_Interp.cxx | 1 - src/SUITApp/SUITApp.cxx | 1 - src/SUITApp/SUITApp_init_python.cxx | 4 ++++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PyInterp/PyInterp_Interp.cxx b/src/PyInterp/PyInterp_Interp.cxx index ba1a386fd..c4ee5d5f6 100644 --- a/src/PyInterp/PyInterp_Interp.cxx +++ b/src/PyInterp/PyInterp_Interp.cxx @@ -242,7 +242,6 @@ void PyInterp_Interp::initialize() PyObjWrapper m(PyImport_ImportModule("codeop")); if(!m) { PyErr_Print(); - PyEval_ReleaseLock(); return; } diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index ee301cb25..1f693f34b 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -252,7 +252,6 @@ int main( int argc, char* argv[] ) int _argc = 1; char* _argv[] = {(char*)""}; SUIT_PYTHON::init_python(_argc,_argv); - PyEval_ReleaseLock(); #endif SUIT_Application* theApp = aSession->startApplication( argList.first() ); diff --git a/src/SUITApp/SUITApp_init_python.cxx b/src/SUITApp/SUITApp_init_python.cxx index 504bd14d8..6bf01ab0e 100644 --- a/src/SUITApp/SUITApp_init_python.cxx +++ b/src/SUITApp/SUITApp_init_python.cxx @@ -34,6 +34,10 @@ void SUIT_PYTHON::init_python(int argc, char **argv) Py_Initialize(); // Initialize the interpreter PySys_SetArgv(argc, argv); PyEval_InitThreads(); // Create (and acquire) the interpreter lock - can be called many times + + // Py_InitThreads acquires the GIL + PyThreadState *pts = PyGILState_GetThisThreadState(); + PyEval_ReleaseThread(pts); SUIT_PYTHON::initialized = true; } -- 2.39.2