WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
Py_END_ALLOW_THREADS!!!
- The function PyEval_InitThreads() should be called only from
- init_thread() in "_threadmodule.c".
-
Note that not yet all candidates have been converted to use this
mechanism!
*/
def test_bpo20891(self):
"""
- bpo-20891: Calling PyGILState_Ensure in a non-Python thread before
- calling PyEval_InitThreads() must not crash. PyGILState_Ensure() must
- call PyEval_InitThreads() for us in this case.
+ bpo-20891: Calling PyGILState_Ensure in a non-Python thread must not
+ crash.
"""
out, err = self.run_embedded_interpreter("test_bpo20891")
self.assertEqual(out, '')
ob_type is the metatype (the 'type'), defaults to PyType_Type,
tp_base is the base type, defaults to 'object' aka PyBaseObject_Type.
*/
- PyEval_InitThreads();
m = PyModule_Create(&_ctypesmodule);
if (!m)
return NULL;
{
if (!Py_IsInitialized()) {
Py_Initialize();
- PyEval_InitThreads();
}
}
return NULL;
}
- /* Ensure Python is set up for threading */
- PyEval_InitThreads();
thread_done = PyThread_allocate_lock();
if (thread_done == NULL)
return PyErr_NoMemory();
test_c_thread_t test_c_thread;
long thread;
- PyEval_InitThreads();
-
test_c_thread.start_event = PyThread_allocate_lock();
test_c_thread.exit_event = PyThread_allocate_lock();
test_c_thread.callback = NULL;
Py_INCREF(func);
Py_INCREF(args);
Py_XINCREF(keyw);
- PyEval_InitThreads(); /* Start the interpreter's thread-awareness */
+
ident = PyThread_start_new_thread(t_bootstrap, (void*) boot);
if (ident == PYTHREAD_INVALID_THREAD_ID) {
PyErr_SetString(ThreadError, "can't start new thread");
_testembed_Py_Initialize();
mainstate = PyThreadState_Get();
- PyEval_InitThreads();
PyEval_ReleaseThread(mainstate);
gilstate = PyGILState_Ensure();
/* the test doesn't support custom memory allocators */
putenv("PYTHONMALLOC=");
- /* bpo-20891: Calling PyGILState_Ensure in a non-Python thread before
- calling PyEval_InitThreads() must not crash. PyGILState_Ensure() must
- call PyEval_InitThreads() for us in this case. */
+ /* bpo-20891: Calling PyGILState_Ensure in a non-Python thread must not
+ crash. */
PyThread_type_lock lock = PyThread_allocate_lock();
if (!lock) {
fprintf(stderr, "PyThread_allocate_lock failed!");
_PyRuntimeState *runtime = tstate->interp->runtime;
struct _ceval_runtime_state *ceval = &runtime->ceval;
- /* Check someone has called PyEval_InitThreads() to create the lock */
+ /* Check that _PyEval_InitThreads() was called to create the lock */
assert(gil_created(&ceval->gil));
take_gil(ceval, tstate);
static int
handle_signals(_PyRuntimeState *runtime)
{
- /* Only handle signals on main thread. PyEval_InitThreads must
- * have been called already.
- */
+ /* Only handle signals on main thread */
if (PyThread_get_thread_ident() != runtime->main_thread) {
return 0;
}