comparison Python/pythonrun.c @ 28694:a4154dd5939a legacy-trunk

New PyGILState_ API - implements pep 311, from patch 684256.
author Mark Hammond <mhammond@skippinet.com.au>
date Sat, 19 Apr 2003 15:41:53 +0000
parents 56006d97bcef
children aef01a076ef9
comparison
equal deleted inserted replaced
28693:7922d5f43854 28694:a4154dd5939a
48 static void call_sys_exitfunc(void); 48 static void call_sys_exitfunc(void);
49 static void call_ll_exitfuncs(void); 49 static void call_ll_exitfuncs(void);
50 extern void _PyUnicode_Init(void); 50 extern void _PyUnicode_Init(void);
51 extern void _PyUnicode_Fini(void); 51 extern void _PyUnicode_Fini(void);
52 52
53 #ifdef WITH_THREAD
54 extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);
55 extern void _PyGILState_Fini(void);
56 #endif /* WITH_THREAD */
57
53 int Py_DebugFlag; /* Needed by parser.c */ 58 int Py_DebugFlag; /* Needed by parser.c */
54 int Py_VerboseFlag; /* Needed by import.c */ 59 int Py_VerboseFlag; /* Needed by import.c */
55 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ 60 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */
56 int Py_NoSiteFlag; /* Suppress 'import site' */ 61 int Py_NoSiteFlag; /* Suppress 'import site' */
57 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ 62 int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */
177 initsigs(); /* Signal handling stuff, including initintr() */ 182 initsigs(); /* Signal handling stuff, including initintr() */
178 183
179 initmain(); /* Module __main__ */ 184 initmain(); /* Module __main__ */
180 if (!Py_NoSiteFlag) 185 if (!Py_NoSiteFlag)
181 initsite(); /* Module site */ 186 initsite(); /* Module site */
187
188 /* auto-thread-state API, if available */
189 #ifdef WITH_THREAD
190 _PyGILState_Init(interp, tstate);
191 #endif /* WITH_THREAD */
182 192
183 PyModule_WarningsModule = PyImport_ImportModule("warnings"); 193 PyModule_WarningsModule = PyImport_ImportModule("warnings");
184 194
185 #if defined(Py_USING_UNICODE) && defined(HAVE_LANGINFO_H) && defined(CODESET) 195 #if defined(Py_USING_UNICODE) && defined(HAVE_LANGINFO_H) && defined(CODESET)
186 /* On Unix, set the file system encoding according to the 196 /* On Unix, set the file system encoding according to the
241 * threads created thru it, so this also protects pending imports in 251 * threads created thru it, so this also protects pending imports in
242 * the threads created via Threading. 252 * the threads created via Threading.
243 */ 253 */
244 call_sys_exitfunc(); 254 call_sys_exitfunc();
245 initialized = 0; 255 initialized = 0;
256
257 /* Cleanup auto-thread-state */
258 #ifdef WITH_THREAD
259 _PyGILState_Fini();
260 #endif /* WITH_THREAD */
246 261
247 /* Get current thread state and interpreter pointer */ 262 /* Get current thread state and interpreter pointer */
248 tstate = PyThreadState_Get(); 263 tstate = PyThreadState_Get();
249 interp = tstate->interp; 264 interp = tstate->interp;
250 265