Replies: 1 comment 4 replies
|
What kind of cleanup would you want to do before shutdown? The hub is shutting down, so it isn't really going to matter if things are cleaned up or not. I don't know if it is guaranteed to happen, but there should be a hub status message that says that shutdown has been requested. So perhaps the only other thing would be doing a broadcast message to say that the hub is going away. And that can be detected already by the signal disappearing (although it could disappear for other reasons as well). If you want to clean up stuff when you program exits (like turn off any lights), you can write something like this: def main():
...
try:
main()
except BaseException:
color_sensor.lights.off()
raise |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello, I am wondering if there is any system trigger I can call within the script when the button on the hub is being pressed in order to shutdown the hub - I am trying to basically stop the running program and do some kind of cleanup before the hub shuts down ? Or ideally send the message via ble.
Thanks.
Pavel Cakl
All reactions