Skip to content

Commit

Permalink
Clarify distinction between main thread handling calls and main threa…
Browse files Browse the repository at this point in the history
…d handling signals.
  • Loading branch information
markshannon committed Oct 2, 2023
1 parent 134ae82 commit 200f545
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Python/ceval_gil.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,17 @@ update_eval_breaker_from_thread(PyInterpreterState *interp, PyThreadState *tstat
if (tstate == NULL) {
return;
}
if (_Py_ThreadCanHandleSignals(interp)) {

if (_Py_IsMainThread()) {
int32_t calls_to_do = _Py_atomic_load_int32_relaxed(
&_PyRuntime.ceval.pending_mainthread.calls_to_do);
if (calls_to_do) {
_Py_set_eval_breaker_bit(interp, _PY_CALLS_TO_DO_BIT, 1);
}
if (_Py_atomic_load(&_PyRuntime.signals.is_tripped)) {
_Py_set_eval_breaker_bit(interp, _PY_SIGNALS_PENDING_BIT, 1);
if (!_Py_ThreadCanHandleSignals(interp)) {
if (_Py_atomic_load(&_PyRuntime.signals.is_tripped)) {
_Py_set_eval_breaker_bit(interp, _PY_SIGNALS_PENDING_BIT, 1);
}
}
}
if (tstate->async_exc != NULL) {
Expand Down

0 comments on commit 200f545

Please sign in to comment.