to Py_Initialize will be undone by n calls to Py_Uninitialize.
PyEval_AcquireThread(gtstate);
gtstate = NULL;
Py_Finalize();
+ Py_Finalize();
}
exit(0);
}
if (gtstate)
return;
Py_Initialize(); /* Initialize the interpreter */
+ Py_Initialize(); /* Initialize the interpreter */
PyEval_InitThreads(); /* Create (and acquire) the interpreter lock */
gtstate = PyEval_SaveThread(); /* Release the thread state */
}
PyObject *bimod, *sysmod;
char *p;
- if (initialized)
- Py_FatalError("Py_Initialize: already initialized");
- initialized = 1;
+ if (++initialized > 1)
+ return;
if ((p = getenv("PYTHONDEBUG")) && *p != '\0')
Py_DebugFlag = 1;
call_sys_exitfunc();
- if (!initialized)
+ if (--initialized > 0)
+ return;
+ if (initialized < 0)
Py_FatalError("Py_Finalize: not initialized");
- initialized = 0;
tstate = PyThreadState_Get();
interp = tstate->interp;