I’m running Mopidy 2.2.1 on a Raspberry PI with Raspian 9.4 (stretch).
I’m building a custom Mopidy frontend that uses an RFID tag read to choose songs.
The RFID reader has an executable file that needs to run in the background in order for RFID tags to be read. So in my Mopidy frontend I startup this executable using a subprocess and read this subprocess’s output in a separate thread.
It all works great.
To stop the RFID reader I have to close the subprocess and stop the thread and I ideally I want it to be stopped when Mopidy is stopped (using ctrl+c). But it appears that Mopidy doesn’t have an event for shutdown. So when I stop Mopidy now, Mopidy does its teardown, and then hangs, because it’s waiting for my RFID subprocess and thread to end, which they don’t. How can I hook into Mopidy’s shutdown?