STINNER Victor <vstin...@python.org> added the comment:

This issue reminds me bpo-40082 where I wrote: "The problem on Windows is that 
each CTRL+c is executed in a different thread." I fixed the issue with:

New changeset b54a99d6432de93de85be2b42a63774f8b4581a0 by Victor Stinner in 
branch 'master':
bpo-40082: trip_signal() uses the main interpreter (GH-19441)
https://github.com/python/cpython/commit/b54a99d6432de93de85be2b42a63774f8b4581a0

"Fix the signal handler: it now always uses the main interpreter,
rather than trying to get the current Python thread state."

Here we have to be careful. If _Py_ThreadCanHandleSignals() always return true, 
we may reintroduce bpo-40010 issue: ceval bytecode evaluation loop may be 
interrupted at every single instruction and call eval_frame_handle_pending() 
which does nothing.

COMPUTE_EVAL_BREAKER() decides if the loop must be interrupted.

Rather than modifying _Py_ThreadCanHandleSignals(), I would prefer to modify 
SIGNAL_PENDING_CALLS(). For example, rather than using COMPUTE_EVAL_BREAKER() 
complex logic to decide if the current Python thread must check if there is a 
pending signal, always interrupt and let the thread decide if it has something 
to do.

The second problem is to reset eval_breaker to 0. If there is no pending signal 
and no pending call, eval_frame_handle_pending() leaves eval_breaker unchanged. 
eval_frame_handle_pending() should also be updated to reset eval_breaker in 
this case.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42296>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to