FilipDem / Domoticz-NEST-plugin

NEST Plugin for Domoticz using the Google credentials.
13 stars 4 forks source link

Issue with .isAlive() and python >= 3.9 #33

Closed otto1234 closed 2 years ago

otto1234 commented 2 years ago

Hi Filip,

I downloaded your plugin a few days ago. Nice code.

I did find an issue where the devices would only update once at start. The onHeartbeat thread blows its brains out when it calls .isAlive(). Everything else kept running, though. Turns out that .isAlive() was deprecated in 3.8 and dropped in 3.9. .is_alive() should be backwards compatible with python < 3.9 (I think...)

Here is this the diff:

diff --git a/plugin.py b/plugin.py
index 37a7724..277f7a5 100644
--- a/plugin.py
+++ b/plugin.py
@@ -215,7 +215,7 @@ class BasePlugin:
         Domoticz.Debug("> onMessage called, ignored")

     def startNestPushThread(self, device, field, Level, Unit):
-        if self.NestPushThread is not None and self.NestPushThread.isAlive():
+        if self.NestPushThread is not None and self.NestPushThread.is_alive():
             if self.nest_update_status != _NEST_UPDATE_STATUS_NONE:
                 self.buffer_command_list.append((device, field, Level, Unit))
                 Domoticz.Debug("NestThread still running; command is buffered")
@@ -385,7 +385,7 @@ class BasePlugin:

             # Check pending commands and execute if it is the case
             if self.buffer_command_list:
-                if self.NestThread is not None and self.NestThread.isAlive():
+                if self.NestThread is not None and self.NestThread.is_alive():
                     Domoticz.Debug("NestThread still running")
                 else:
                     if self.nest_update_status == _NEST_UPDATE_STATUS_NONE:
@@ -395,7 +395,7 @@ class BasePlugin:
                         return

             if self.runAgain <= 0:
-                if self.NestThread is not None and self.NestThread.isAlive():
+                if self.NestThread is not None and self.NestThread.is_alive():
                     Domoticz.Debug("NestThread still running")
                 else:
                     self.NestThread = threading.Thread(name="NestThread", target=BasePlugin.NestUpdate, args=(self,))

thanks Douglas

FilipDem commented 2 years ago

Hi Douglas, First of thanks for your feedback. A while ago I refactored the plugin (especially the threading part). This doesn't use the isAlive anymore. I didn't pushed it yet on github because I wanted to run it a while at my side... This is working perfectly so your trigger will make me push it on github. So you will see it coming soon. If you are happy with the plugin, there is always an opportunity for a small contribution (however it is a free choice). F