Skip to content

Commit da0d844

Browse files
committed
Clarify distinction between main thread handling calls and main thread handling signals.
1 parent 134ae82 commit da0d844

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Python/ceval_gil.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,17 @@ update_eval_breaker_from_thread(PyInterpreterState *interp, PyThreadState *tstat
6868
if (tstate == NULL) {
6969
return;
7070
}
71-
if (_Py_ThreadCanHandleSignals(interp)) {
71+
72+
if (_Py_IsMainThread()) {
7273
int32_t calls_to_do = _Py_atomic_load_int32_relaxed(
7374
&_PyRuntime.ceval.pending_mainthread.calls_to_do);
7475
if (calls_to_do) {
7576
_Py_set_eval_breaker_bit(interp, _PY_CALLS_TO_DO_BIT, 1);
7677
}
77-
if (_Py_atomic_load(&_PyRuntime.signals.is_tripped)) {
78-
_Py_set_eval_breaker_bit(interp, _PY_SIGNALS_PENDING_BIT, 1);
78+
if (_Py_ThreadCanHandleSignals(interp)) {
79+
if (_Py_atomic_load(&_PyRuntime.signals.is_tripped)) {
80+
_Py_set_eval_breaker_bit(interp, _PY_SIGNALS_PENDING_BIT, 1);
81+
}
7982
}
8083
}
8184
if (tstate->async_exc != NULL) {

0 commit comments

Comments
 (0)