This post was flagged by the community and is temporarily hidden.
Click once on the exec node, read the info tab: send msg.kill with a payload of the signal (or send nothing in the payload and it will default to SIGTERM).
hi @bakman2 thanks for the reply but the kill is just stopping the script not cleanly exiting it and zeroing out the leds
What does the python script look like? Is there a
except KeyboardInterrupt in it to handle the shutdown procedure when the script is killed? That won't be executed on sending a SIGTERM. However, you could either work around it, or follow the python docs and send a SIGINT instead:
But since you're executing from an external process it's better to just write it to use signals instead to catch an interrupt.
I've put the strandtest.py file on the GitHub repo what's the best way to stop it when needed or modify it to stop more elegantly?
Like I expected, this line is what causes your problem:
See my previous post, when using the exec node the default signal sent is SIGTERM if no other signal is specified (see Bakman's response). In order to have the KeyboardInterrupt sent (which equals ctrl-c) you send a sigint. However, depending on the type of job it might still not run the code when you send a SIGINT instead of a SIGTERM.
The best workaround for that is to write a handler to have code execute when a SIGINT is detected, where your code to execute would be the equivalent of your line 115 in the current version of that script. Read the page from the python docs I linked in my previous message first, then check the example at the bottom of the page except with a handler for SIGINT that you will have to write: https://docs.python.org/3/library/signal.html#example
Excellent thank you, i'll step through it.