I'm trying to set up a sort of basic screensaver on a Raspberry PI.
I'm using python because I like it a lot more than bash.
The script uses popen to call feh and display a slideshow.
There's also NodeRed running on this Pi, and that manages the actions bound to a few GPIO buttons.
I would like to intercept those button inputs to stop the slideshow.
I thought of 3 ways:

use NodeRed to kill (-15 or -9) feh. But this leaves behind a "defunct" process, and python should rely on the absence of the spawned process before spawning a new one
use the RPi.GPIO library and bind a callback event to the button press. This doesn't work because it throws the error that the channel (i.e. the GPIO pin) is already in use, and the RPI crashes and has to be power cycled.
use a OS environment variable. This could work, but I don't want to continually be polling the variable. The feh process needs to stop immediately upon a button press.

So how else could this be achieved?
Is there a way to bind a function to some external trigger?
I realized that since the script logic is very simple and only has one task, it would have been easy to use a socket (synchronous and blocking) and wait on that for NodeRed to send its command. And indeed it was
make python wait for external trigger