Steven, thanks for verifying bug on *nix.

On 3/28/2017 2:00 AM, Martin Panter wrote:
On 28 March 2017 at 03:11, Steven D'Aprano <st...@pearwood.info> wrote:
On Mon, Mar 27, 2017 at 10:33:44PM -0400, Terry Reedy wrote:
https://bugs.python.org/issue29926 was opened as an IDLE issue, which
means that most watching the new issues list would ignore it.  But I
think it is an issue with _thread.interrupt_main (which IDLE calls in
respond to ^C) not interrupting time.sleep(n) in main thread*.  I tested
on Windows, don't know yet about OP.  Since there is no Expert's Index
listing for _thread (or threading), I am asking here for someone who
knows anything to take a look.

*
time.sleep(10)
<hit ^C immediately>
<debug print after interrupt_main() shows immediately>
<... remainder of 10 seconds pass>
KeyboardInterrupt


I get similar behaviour under Linux. I don't have the debug print, but
the KeyboardInterrupt doesn't interrupt the sleep until the 10 seconds
are up.

Looking at the implementation, _thread.interrupt_main just calls
PyErr_SetInterrupt. It doesn’t appear to send a signal. I played with
“strace” and couldn’t see any evidence of a signal. I guess it just
sets a flag that will be polled. To actually interrupt the “sleep”
call, you might need to use “pthread_kill” or similar (at least on
Unix).

I copied this to the issue. Eryk Sun suggested a patch for Windows, (and the possibility of using pthread_kill). Can you possibly do one for *nix? This is out of my ballpark, but the bug (relative to console behavior) is a nuisance.

--
Terry Jan Reedy


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to