Commit d5c62dc4 authored by Clinton Stimpson's avatar Clinton Stimpson
Browse files

ENH: Postponing some Python thread related calls until just before the testing

      thread runs.
      Addresses issue #6553.
parent aad4fc26
...@@ -366,7 +366,6 @@ class pqPythonEventSource::pqInternal ...@@ -366,7 +366,6 @@ class pqPythonEventSource::pqInternal
{ {
public: public:
QString FileName; QString FileName;
PyThreadState* MainThreadState;
}; };
pqPythonEventSource::pqPythonEventSource(QObject* p) pqPythonEventSource::pqPythonEventSource(QObject* p)
...@@ -381,17 +380,11 @@ pqPythonEventSource::pqPythonEventSource(QObject* p) ...@@ -381,17 +380,11 @@ pqPythonEventSource::pqPythonEventSource(QObject* p)
#ifdef SIGINT #ifdef SIGINT
signal(SIGINT, SIG_DFL); signal(SIGINT, SIG_DFL);
#endif #endif
PyEval_InitThreads();
PyEval_ReleaseLock();
}
PyEval_AcquireLock();
// add QtTesting to python's inittab, so it is // add QtTesting to python's inittab, so it is
// available to all interpreters // available to all interpreters
PyImport_AppendInittab(const_cast<char*>("QtTesting"), initQtTesting); PyImport_AppendInittab(const_cast<char*>("QtTesting"), initQtTesting);
}
PyEval_ReleaseLock();
} }
pqPythonEventSource::~pqPythonEventSource() pqPythonEventSource::~pqPythonEventSource()
...@@ -500,7 +493,8 @@ void pqPythonEventSource::run() ...@@ -500,7 +493,8 @@ void pqPythonEventSource::run()
return; return;
} }
PyEval_AcquireLock(); PyEval_InitThreads();
PyEval_ReleaseLock();
PyThreadState* curState = PyThreadState_Get(); PyThreadState* curState = PyThreadState_Get();
PyThreadState* threadState = Py_NewInterpreter(); PyThreadState* threadState = Py_NewInterpreter();
...@@ -512,9 +506,9 @@ void pqPythonEventSource::run() ...@@ -512,9 +506,9 @@ void pqPythonEventSource::run()
QByteArray wholeFile = file.readAll(); QByteArray wholeFile = file.readAll();
int result = PyRun_SimpleString(wholeFile.data()) == 0 ? 0 : 1; int result = PyRun_SimpleString(wholeFile.data()) == 0 ? 0 : 1;
PyThreadState_Swap(threadState);
Py_EndInterpreter(threadState); Py_EndInterpreter(threadState);
PyThreadState_Swap(curState); PyThreadState_Swap(curState);
PyEval_ReleaseLock();
this->done(result); 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