[New-bugs-announce] [issue29926] time.sleep ignores keyboard interrupt in IDLE

Mark report at bugs.python.org
Mon Mar 27 18:51:11 EDT 2017


New submission from Mark:

Consider the following code, typed interactively:

>>> import time
>>> time.sleep(1e6)

This will sleep for a bit over one and a half weeks.  If this was typed in error, you may want to interrupt it.  If using the command line, this is easy: just use Ctrl-C.  If using IDLE, Ctrl-C has no effect.  One could attempt to restart the shell with Ctrl-F6, which seems to work, but in fact the process remains in the background, hung until the timeout expires.  There are two obvious workarounds: one is to sleep in a separate thread, so as to avoid blocking the main thread, and the other is to use a loop with smaller sleep increments:

for ii in range(1e5): sleep(10)

Now it only takes 10 seconds to interrupt a sleep.  But these are both clumsy workarounds.  They're so clumsy that I think I'm not going to use IDLE for this particular program and just use python -I.  Would be nice if this were fixed.

----------
assignee: terry.reedy
components: IDLE
messages: 290663
nosy: Mark, terry.reedy
priority: normal
severity: normal
status: open
title: time.sleep ignores keyboard interrupt in IDLE
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29926>
_______________________________________


More information about the New-bugs-announce mailing list