Skip to content

Commit

Permalink
disable stopInterpreter function for now
Browse files Browse the repository at this point in the history
  • Loading branch information
fridgerator committed Oct 16, 2019
1 parent e54860c commit 60d3bc8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 13 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ void stopInterpreter(const v8::FunctionCallbackInfo<v8::Value>& 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<v8::Value> &args)
Expand Down Expand Up @@ -158,7 +158,13 @@ void eval(const Nan::FunctionCallbackInfo<v8::Value> &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));
}

Expand Down Expand Up @@ -381,11 +387,11 @@ NODE_MODULE_INITIALIZER(v8::Local<v8::Object> 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)
Expand Down
10 changes: 5 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ describe('nodePython', () => {
})
})

describe('stopInterpreter', () => {
it('should stop the interpreter', () => {
nodePython.stopInterpreter()
})
})
// describe('stopInterpreter', () => {
// it('should stop the interpreter', () => {
// nodePython.stopInterpreter()
// })
// })
})

0 comments on commit 60d3bc8

Please sign in to comment.