From 60d3bc876381978667f9c88e79d051ee1e78be66 Mon Sep 17 00:00:00 2001 From: Nick Franken Date: Wed, 16 Oct 2019 14:04:17 -0500 Subject: [PATCH] disable stopInterpreter function for now --- index.d.ts | 2 +- src/main.cpp | 20 +++++++++++++------- test.js | 10 +++++----- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/index.d.ts b/index.d.ts index c5be6dc..fd4dcd3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -15,7 +15,7 @@ declare module '@fridgerator/pynode' { /** * Stops the Python interpreter */ - export function stopInterpreter(pythonpath?: string): void; + // export function stopInterpreter(pythonpath?: string): void; /** * Add an additional path as a python module search path diff --git a/src/main.cpp b/src/main.cpp index 1ca45db..6a9d579 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -93,9 +93,9 @@ void stopInterpreter(const v8::FunctionCallbackInfo& info) auto isInitialized = Py_IsInitialized(); if (isInitialized == 0) return; - Py_Finalize(); Py_DECREF(data->pModule); data->pModule = NULL; + Py_Finalize(); } void appendSysPath(const Nan::FunctionCallbackInfo &args) @@ -158,7 +158,13 @@ void eval(const Nan::FunctionCallbackInfo &args) } Nan::Utf8String statement(args[0]); - int response = PyRun_SimpleString(*statement); + int response; + { + py_context ctx; + + response = PyRun_SimpleString(*statement); + } + // int response = PyRun_SimpleString(*statement); args.GetReturnValue().Set(Nan::New(response)); } @@ -381,11 +387,11 @@ NODE_MODULE_INITIALIZER(v8::Local exports, v8::FunctionTemplate::New(isolate, startInterpreter, external) ->GetFunction(context).ToLocalChecked()).FromJust(); - exports->Set(context, - v8::String::NewFromUtf8(isolate, "stopInterpreter", v8::NewStringType::kNormal) - .ToLocalChecked(), - v8::FunctionTemplate::New(isolate, stopInterpreter, external) - ->GetFunction(context).ToLocalChecked()).FromJust(); + // exports->Set(context, + // v8::String::NewFromUtf8(isolate, "stopInterpreter", v8::NewStringType::kNormal) + // .ToLocalChecked(), + // v8::FunctionTemplate::New(isolate, stopInterpreter, external) + // ->GetFunction(context).ToLocalChecked()).FromJust(); exports->Set(context, v8::String::NewFromUtf8(isolate, "openFile", v8::NewStringType::kNormal) diff --git a/test.js b/test.js index 8daaa69..97c54ad 100644 --- a/test.js +++ b/test.js @@ -262,9 +262,9 @@ describe('nodePython', () => { }) }) - describe('stopInterpreter', () => { - it('should stop the interpreter', () => { - nodePython.stopInterpreter() - }) - }) + // describe('stopInterpreter', () => { + // it('should stop the interpreter', () => { + // nodePython.stopInterpreter() + // }) + // }) })