mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
gh-104341: Adjust tstate_must_exit() to Respect Interpreter Finalization (gh-104437)
With the move to a per-interpreter GIL, this check slipped through the cracks.
This commit is contained in:
parent
cb88ae635e
commit
26baa747c2
11 changed files with 56 additions and 10 deletions
|
|
@ -526,7 +526,7 @@ future_init(FutureObj *fut, PyObject *loop)
|
|||
if (is_true < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (is_true && !_Py_IsFinalizing()) {
|
||||
if (is_true && !_Py_IsInterpreterFinalizing(PyInterpreterState_Get())) {
|
||||
/* Only try to capture the traceback if the interpreter is not being
|
||||
finalized. The original motivation to add a `_Py_IsFinalizing()`
|
||||
call was to prevent SIGSEGV when a Future is created in a __del__
|
||||
|
|
|
|||
|
|
@ -293,7 +293,8 @@ _enter_buffered_busy(buffered *self)
|
|||
"reentrant call inside %R", self);
|
||||
return 0;
|
||||
}
|
||||
relax_locking = _Py_IsFinalizing();
|
||||
PyInterpreterState *interp = PyInterpreterState_Get();
|
||||
relax_locking = _Py_IsInterpreterFinalizing(interp);
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
if (!relax_locking)
|
||||
st = PyThread_acquire_lock(self->lock, 1);
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ connection_close(pysqlite_Connection *self)
|
|||
{
|
||||
/* If close is implicitly called as a result of interpreter
|
||||
* tear-down, we must not call back into Python. */
|
||||
if (_Py_IsFinalizing()) {
|
||||
if (_Py_IsInterpreterFinalizing(PyInterpreterState_Get())) {
|
||||
remove_callbacks(self->db);
|
||||
}
|
||||
(void)connection_exec_stmt(self, "ROLLBACK");
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ overlapped_dealloc(OverlappedObject *self)
|
|||
{
|
||||
/* The operation is no longer pending -- nothing to do. */
|
||||
}
|
||||
else if (_Py_IsFinalizing())
|
||||
else if (_Py_IsInterpreterFinalizing(PyInterpreterState_Get()))
|
||||
{
|
||||
/* The operation is still pending -- give a warning. This
|
||||
will probably only happen on Windows XP. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue