trakt / script.trakt

Trakt.tv movie and TV show scrobbler for Kodi
GNU General Public License v2.0
318 stars 149 forks source link

Python 3.9.0 "AttributeError: 'syncThread' object has no attribute 'isAlive'" #520

Closed mazzoq closed 3 years ago

mazzoq commented 3 years ago

https://bugs.python.org/issue37804

Kodi 19 Beta 2, Fedora 33, Python 3.9.0, I'm getting the following when attempting a sync.

2020-12-15 17:24:41.552 T:3080    DEBUG <general>: [script.trakt] resources.lib.service: Dispatch: {'action': 'manualSync', 'silent': False, 'library': 'all'}
2020-12-15 17:24:41.553 T:3080    FATAL <general>: [script.trakt] resources.lib.service: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <type 'AttributeError'>
                                                   Error Contents: ("'syncThread' object has no attribute 'isAlive'",)
                                                   Traceback (most recent call last):
                                                     File "/home/kodi/.kodi/addons/script.trakt/resources/lib/service.py", line 71, in _       dispatch
                                                       if not self.syncThread.isAlive():
                                                   AttributeError: 'syncThread' object has 

I've confirmed that the following code change fixes the issue for me, but I'm not sure how best to avoid breaking backwards compatibility?

diff --git a/resources/lib/service.py b/resources/lib/service.py
index dff7871..757972d 100644
--- a/resources/lib/service.py
+++ b/resources/lib/service.py
@@ -68,7 +68,7 @@ class traktService:
                 del data['action']
                 self.doAddToWatchlist(data)
             elif action == 'manualSync':
-                if not self.syncThread.isAlive():
+                if not self.syncThread.is_alive():
                     logger.debug("Performing a manual sync.")
                     self.doSync(
                         manual=True, silent=data['silent'], library=data['library'])
@@ -132,7 +132,7 @@ class traktService:
         del self.Monitor

         # check if sync thread is running, if so, join it.
-        if self.syncThread.isAlive():
+        if self.syncThread.is_alive():
             self.syncThread.join()

     def doManualRating(self, data):
razzeee commented 3 years ago

I remember, that there is a way to ask for the python version, but I can't remember the exact syntax.

razzeee commented 3 years ago

Seems to be around since 2.6 https://docs.python.org/2/library/threading.html#threading.Thread.is_alive

razzeee commented 3 years ago

Should be fixed by https://github.com/trakt/script.trakt/commit/5eb6e975b63308bd5200bd3b431b3113b0d93b67