I'm working on a plugin that responds to an action. When the action is called, it does some stuff and it's done. However, 99.9% of the time it doesn't do anything.
When the action is called, the plugin will need to run a concurrent thread. This all works fine, but I'd like to be able to start and stop that thread so that during the 99.9% of the time when the plugin isn't doing anything, the thread isn't running either.
I've tried stopConcurrentThread() and that does in fact shutdown the thread (because self.StopThread is set to True). However, Indigo tries to restart it every 10 seconds. I suspect this is because stopConcurrentThread() is not something the plugin should call, but instead, a method to implement if extra code is needed when Indio is shutting down the concurrent process. Correct?
I've also tried prepareToSleep(), but that applies to devices and triggers, which this plugin doesn't use.
I also tried using a Python thread, and that mostly works. The issue I ran into there was that exception logging from the thread did not show up in the Indigo log. It seems like this is fixable, but I'm not sure how to do that. Any thoughts on using a Python thread?
So the functionality I'm most interested in: Can the plugin tell Indigo to stop trying to run the concurrent thread defined in runConcurrentThread(), then tell it to start running again?
Thanks for any help!