Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    KeyboardInterrupt Exception not handled after pushing Ctrl-C

    Scheduled Pinned Locked Moved LoPy
    3 Posts 2 Posters 1.5k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • robert-hhR Offline
      robert-hh
      last edited by

      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
      
      1 Reply Last reply Reply Quote 0
      • R Offline
        Ralph
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh
          last edited by

          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

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom