mirror of
https://github.com/python/cpython.git
synced 2025-10-13 10:23:28 +00:00
bpo-39877: _PyRuntimeState.finalizing becomes atomic (GH-18816)
Convert _PyRuntimeState.finalizing field to an atomic variable: * Rename it to _finalizing * Change its type to _Py_atomic_address * Add _PyRuntimeState_GetFinalizing() and _PyRuntimeState_SetFinalizing() functions * Remove _Py_CURRENTLY_FINALIZING() function: replace it with testing directly _PyRuntimeState_GetFinalizing() value Convert _PyRuntimeState_GetThreadState() to static inline function.
This commit is contained in:
parent
557287075c
commit
7b3c252dc7
5 changed files with 29 additions and 15 deletions
|
@ -240,7 +240,8 @@ exit_thread_if_finalizing(PyThreadState *tstate)
|
|||
{
|
||||
_PyRuntimeState *runtime = tstate->interp->runtime;
|
||||
/* _Py_Finalizing is protected by the GIL */
|
||||
if (runtime->finalizing != NULL && !_Py_CURRENTLY_FINALIZING(runtime, tstate)) {
|
||||
PyThreadState *finalizing = _PyRuntimeState_GetFinalizing(runtime);
|
||||
if (finalizing != NULL && finalizing != tstate) {
|
||||
drop_gil(&runtime->ceval, tstate);
|
||||
PyThread_exit_thread();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue