Commit 04dbcb3b authored by Berk Geveci's avatar Berk Geveci
Browse files

BUG: Fixed BUG #4823. The issue arose because of multithreading. When testing...

BUG: Fixed BUG #4823. The issue arose because of multithreading. When testing with python was enabled, we have an interpretor initialized in a separate thread. This requires that we use correct locking mechaism for python to work correctly. Fixed that.
Currently, in the python shell, there is no way to access the connection that the client is currently connected to. Added default initialization so that paraview.ActiveConnection will point to the same connection that the client is currently connected to when the python
shell is opened.
parent 13c7348d
......@@ -430,6 +430,8 @@ pqPythonEventSource::pqPythonEventSource(QObject* p)
// add QtTesting to python's inittab, so it is
// available to all interpreters
PyImport_AppendInittab(const_cast<char*>("QtTesting"), initQtTesting);
PyEval_ReleaseLock();
}
pqPythonEventSource::~pqPythonEventSource()
......@@ -538,15 +540,21 @@ void pqPythonEventSource::run()
return;
}
PyEval_AcquireLock();
PyThreadState* curState = PyThreadState_Get();
PyThreadState* threadState = Py_NewInterpreter();
Instance = this;
PyThreadState_Swap(threadState);
// finally run the script
QByteArray wholeFile = file.readAll();
int result = PyRun_SimpleString(wholeFile.data()) == 0 ? 0 : 1;
Py_EndInterpreter(threadState);
PyThreadState_Swap(curState);
PyEval_ReleaseLock();
this->done(result);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment