UniversalDevicesInc / polyglot-v2-python-interface

Python Interface for NodeServers to Polyglot v2
MIT License
7 stars 4 forks source link

MQTT is shut down prior to notifying the stop observers #7

Closed whittedb closed 6 years ago

whittedb commented 6 years ago

It would be nice to have the stop observers called prior to MQTT shutdown so drivers can be updated before shutting down. Use case: Update a status in ISY indicating the node is not available.

Are there any implications to just moving the notification loop above the MQTT shutdown code? I'm not sure if the order of those actions was intentional for some reason.

exking commented 6 years ago

There is a stop() method on the controller - is that not enough for your needs?

whittedb commented 6 years ago

That's what I'm using but it's called "after" the disconnect from MQTT.

exking commented 6 years ago

I see. I'm guessing that reason behind it - if stop() takes too much time - we still want to disconnect MQTT before Polyglot forcefully kills us.

firstone commented 6 years ago

More than timing, if stop locks up, or node server otherwise is not functioning, this might prevent restart. To do it properly, you'd have to call stop from separate thread with timeout. While doable, seems like an over kill here. Technically, restart is abnormal condition. Trying to synchronize state in abnormal condition probably isn't worth the trouble.

whittedb commented 6 years ago

Good point @firstone. I suppose that if the controller is not online, then the rest of the nodes aren't either. I can live with that. Thanks for the input.