mirror of
https://github.com/python/cpython.git
synced 2025-09-01 06:28:36 +00:00
New PyGILState_ API - implements pep 311, from patch 684256.
This commit is contained in:
parent
e36b690087
commit
8d98d2cb95
10 changed files with 395 additions and 131 deletions
|
@ -50,6 +50,11 @@ static void call_ll_exitfuncs(void);
|
|||
extern void _PyUnicode_Init(void);
|
||||
extern void _PyUnicode_Fini(void);
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);
|
||||
extern void _PyGILState_Fini(void);
|
||||
#endif /* WITH_THREAD */
|
||||
|
||||
int Py_DebugFlag; /* Needed by parser.c */
|
||||
int Py_VerboseFlag; /* Needed by import.c */
|
||||
int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */
|
||||
|
@ -180,6 +185,11 @@ Py_Initialize(void)
|
|||
if (!Py_NoSiteFlag)
|
||||
initsite(); /* Module site */
|
||||
|
||||
/* auto-thread-state API, if available */
|
||||
#ifdef WITH_THREAD
|
||||
_PyGILState_Init(interp, tstate);
|
||||
#endif /* WITH_THREAD */
|
||||
|
||||
PyModule_WarningsModule = PyImport_ImportModule("warnings");
|
||||
|
||||
#if defined(Py_USING_UNICODE) && defined(HAVE_LANGINFO_H) && defined(CODESET)
|
||||
|
@ -244,6 +254,11 @@ Py_Finalize(void)
|
|||
call_sys_exitfunc();
|
||||
initialized = 0;
|
||||
|
||||
/* Cleanup auto-thread-state */
|
||||
#ifdef WITH_THREAD
|
||||
_PyGILState_Fini();
|
||||
#endif /* WITH_THREAD */
|
||||
|
||||
/* Get current thread state and interpreter pointer */
|
||||
tstate = PyThreadState_Get();
|
||||
interp = tstate->interp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue