Do not create new python interpreter
This commit is contained in:
parent
cf331ca2a7
commit
e15b339d41
@ -28,8 +28,6 @@ SOFTWARE.
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include "pyredirector.h"
|
#include "pyredirector.h"
|
||||||
|
|
||||||
static PyThreadState *MainThreadState = NULL;
|
|
||||||
|
|
||||||
static PyThreadState *m_threadState = NULL;
|
static PyThreadState *m_threadState = NULL;
|
||||||
static PyObject *glb = NULL;
|
static PyObject *glb = NULL;
|
||||||
static PyObject *loc = NULL;
|
static PyObject *loc = NULL;
|
||||||
@ -125,9 +123,8 @@ void pyinterpreter_preinit()
|
|||||||
void pyinterpreter_initialize()
|
void pyinterpreter_initialize()
|
||||||
{
|
{
|
||||||
PyEval_InitThreads();
|
PyEval_InitThreads();
|
||||||
MainThreadState = PyEval_SaveThread();
|
m_threadState = PyEval_SaveThread();
|
||||||
PyEval_AcquireThread(MainThreadState);
|
PyEval_AcquireThread(m_threadState);
|
||||||
m_threadState = Py_NewInterpreter();
|
|
||||||
|
|
||||||
PyObject *module = PyImport_ImportModule("__main__");
|
PyObject *module = PyImport_ImportModule("__main__");
|
||||||
loc = glb = PyModule_GetDict(module);
|
loc = glb = PyModule_GetDict(module);
|
||||||
@ -147,11 +144,7 @@ void pyinterpreter_finalize()
|
|||||||
{
|
{
|
||||||
m_suggestions.clear();
|
m_suggestions.clear();
|
||||||
|
|
||||||
PyEval_AcquireThread(m_threadState);
|
PyEval_RestoreThread(m_threadState);
|
||||||
Py_EndInterpreter(m_threadState);
|
|
||||||
PyEval_ReleaseLock();
|
|
||||||
|
|
||||||
PyEval_RestoreThread(MainThreadState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pyinterpreter_aquire()
|
void pyinterpreter_aquire()
|
||||||
|
Loading…
Reference in New Issue
Block a user