Skip to content

REPL: Ctrl-C doesn't raise KeyboardInterrupt #1092

Closed
@notro

Description

@notro

Pressing Ctrl-C when sleeping aborts the operation but doesn't raise an exception like in CPython.

CircuitPython:

Adafruit CircuitPython patchbase-3-gedb366e7f-dirty on 2018-08-06; Adafruit Feather M0 Express with samd21g18
>>> import time
>>> time.sleep(10)
>>>

CPython:

Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.sleep(10)
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyboardInterrupt
>>>

Another problem is that that the Ctrl-C event gets stuck so the next sleep is also aborted:

Adafruit CircuitPython patchbase-3-gedb366e7f-dirty on 2018-08-06; Adafruit Feather M0 Express with samd21g18
>>> import time
>>> t = time.monotonic(); time.sleep(1); print(time.monotonic() - t)
1.0
>>> t = time.monotonic(); time.sleep(1); print(time.monotonic() - t)
[[PRESS CTRL-C]]
0.333984
>>> t = time.monotonic(); time.sleep(1); print(time.monotonic() - t)
0.0
>>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions