Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPIO channels are not closed on Ctrl+C termination #2

Open
ptodorov0 opened this issue May 25, 2014 · 0 comments
Open

GPIO channels are not closed on Ctrl+C termination #2

ptodorov0 opened this issue May 25, 2014 · 0 comments

Comments

@ptodorov0
Copy link

If you terminate alarmd.py or keypadd.py with Ctrl+C or Ctrl+Z and then relauch you will see that the GPIO channels cannot be reopened because they are already in use. My solution was to add

include signal
include sys

... and just before the "while True:" ...

def signal_handler(signal, frame):
    print '[EXIT] You have just terminated the script execution!'
    io.cleanup()
    sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)

Change "io.cleanup()" to "GPIO.cleanup()" in order to use it in keypadd.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant