summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PluginAlgorithm.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/PluginAlgorithm.cpp b/src/PluginAlgorithm.cpp
index 4066e30..e79c77b 100644
--- a/src/PluginAlgorithm.cpp
+++ b/src/PluginAlgorithm.cpp
@@ -112,12 +112,14 @@ bool CPluginAlgorithm::initialize(const Config& _cfg){
void CPluginAlgorithm::run(int _iNrIterations){
if(instance==NULL) return;
+ PyGILState_STATE state = PyGILState_Ensure();
PyObject *retVal = PyObject_CallMethod(instance, "run", "i",_iNrIterations);
if(retVal==NULL){
logPythonError();
- return;
+ }else{
+ Py_DECREF(retVal);
}
- Py_DECREF(retVal);
+ PyGILState_Release(state);
}
void fixLapackLoading(){
@@ -147,7 +149,10 @@ void fixLapackLoading(){
}
CPluginAlgorithmFactory::CPluginAlgorithmFactory(){
- Py_Initialize();
+ if(!Py_IsInitialized()){
+ Py_Initialize();
+ PyEval_InitThreads();
+ }
#ifndef _MSC_VER
if(astra::running_in_matlab) fixLapackLoading();
#endif