Skip to content

Instantly share code, notes, and snippets.

@naotaco
Created March 25, 2015 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naotaco/54b9b5a9edaac1d24c85 to your computer and use it in GitHub Desktop.
Save naotaco/54b9b5a9edaac1d24c85 to your computer and use it in GitHub Desktop.
shutdown codes
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