Skip to content

examples/7color/buttons.py doesn't stop cleanly #215

@dolmen

Description

@dolmen

examples/7color/buttons.py crashes with a stacktrace when the program is interrupted with Ctrl+C. I expected a clean exit, so exception KeyboardInterrupt should be caught.

$ ./buttons.py 
buttons.py - Detect which button has been pressed

This example should demonstrate how to:
 1. set up gpiod to read buttons,
 2. determine which button has been pressed

Press Ctrl+C to exit!


Button press detected on GPIO #5 label: A
Button press detected on GPIO #6 label: B
Button press detected on GPIO #16 label: C
Button press detected on GPIO #24 label: D
Button press detected on GPIO #24 label: D
^CTraceback (most recent call last):
  File "/home/dolmen/Pimoroni/inky/examples/7color/./buttons.py", line 62, in <module>
    for event in request.read_edge_events():
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dolmen/.virtualenvs/pimoroni/lib/python3.11/site-packages/gpiod/line_request.py", line 223, in read_edge_events
    return cast(_ext.Request, self._req).read_edge_events(max_events)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions