KeyboardInterrupt Exception not handled after pushing Ctrl-C



  • Version; MicroPython v1.8.6-251-g2fb950d on 2016-12-16; LoPy with ESP32

    The KeyboardInterrupt Exception is not handled as such, and not as another exception type.
    he follwoin small piece of code should catch Ctr-C, but it does. Other ports of MicroPython work properly, and even the WiPy 1 port does at least not terminate (it ignores Ctrl-C)

    import sys
    while (True):
        try:
            c=sys.stdin.read(1)
            sys.stdout.write(c)
        except KeyboardInterrupt:
            print("received keyboard interrupt")
        except:
            print("Got another interrupt")
        if c == "q":
            break
    


  • Thanks @Ralph. On WIpy 1 there is however a little inconvenience in that the keyboard interrupt is not flagged immediately, but only after another character is typed. This behavior exists since ever, I reported it but it was never fixed.
    Best regards, Robert



  • Hi @robert-hh,

    I tested it and this seems to be a bug in the firmware. I can't seem to catch the keyboardinterrupt. On the WiPy 1.0 it does work.

    I added this bug to Github issues now, you can find it here. If you find more specific bugs like this in the future, please post it there.

    Regards,
    Ralph


Log in to reply
 

Pycom on Twitter