Created
March 25, 2015 15:31
-
-
Save naotaco/54b9b5a9edaac1d24c85 to your computer and use it in GitHub Desktop.
shutdown codes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _on_exit(): | |
print ("at exit") | |
turn_off() | |
time.sleep(1) | |
GPIO.cleanup() | |
print ("exit handler triggered") | |
time.sleep(1) | |
def on_exit(sig, func=None): | |
_on_exit() | |
# register function to run before shutdown | |
import signal | |
signal.signal(signal.SIGTERM, on_exit) | |
atexit.register(_on_exit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment