File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @fridgerator/pynode" ,
3- "version" : " 0.5.1 " ,
4- "description" : " Node <-> Python interopability " ,
3+ "version" : " 0.5.2 " ,
4+ "description" : " Node <-> Python interoperability " ,
55 "main" : " build/Release/PyNode" ,
66 "author" : " Nick Franken <shnick@gmail.com>" ,
77 "license" : " MIT" ,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ Napi::Value StartInterpreter(const Napi::CallbackInfo &info) {
1919 mbstowcs (&path[0 ], pathString.c_str (), pathString.length ());
2020 Py_SetPath (path.c_str ());
2121 }
22-
22+
2323 PyImport_AppendInittab (" pynode" , &PyInit_jswrapper);
2424
2525 int isInitialized = Py_IsInitialized ();
@@ -31,6 +31,9 @@ Napi::Value StartInterpreter(const Napi::CallbackInfo &info) {
3131 if (threadsInitialized == 0 )
3232 PyEval_InitThreads ();
3333
34+ /* Ensure GIL */
35+ py_thread_context ctx;
36+
3437 /* Load PyNode's own module into Python. This makes WrappedJSObject instances
3538 behave better (eg, having attributes) */
3639 PyObject *pName;
@@ -43,9 +46,6 @@ Napi::Value StartInterpreter(const Napi::CallbackInfo &info) {
4346 .ThrowAsJavaScriptException ();
4447 }
4548
46- /* Release the GIL. The other entry points back into Python re-acquire it */
47- PyEval_SaveThread ();
48-
4949 return env.Null ();
5050}
5151
Original file line number Diff line number Diff line change @@ -261,6 +261,12 @@ describe('nodePython', () => {
261261 } )
262262 } )
263263
264+ describe ( 'duplicate startInterpreter' , ( ) => {
265+ it ( 'No error should happen when calling startInterpreter again' , ( ) => {
266+ nodePython . startInterpreter ( ) ;
267+ } ) ;
268+ } )
269+
264270 // describe('stopInterpreter', () => {
265271 // it('should stop the interpreter', () => {
266272 // nodePython.stopInterpreter()
You can’t perform that action at this time.
0 commit comments