From 0f73bf1840a9dcc1b15b4cdfa84b21f960ea6ffa Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Fri, 15 Jan 2016 08:53:16 +0100 Subject: [PATCH] Enable library sync threads to crash correctly --- resources/lib/librarysync.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index e0b1fdb6..c785d23b 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -46,9 +46,10 @@ class ThreadedGetMetadata(threading.Thread): self.lock = lock self.userStop = userStop self._shouldstop = threading.Event() + self.addonName = clientinfo.ClientInfo().getAddonName() threading.Thread.__init__(self) - def run(self): + def run_internal(self): plx = PlexAPI.PlexAPI() global getMetadataCount while self.stopped() is False: @@ -72,6 +73,16 @@ class ThreadedGetMetadata(threading.Thread): # signals to queue job is done self.queue.task_done() + def run(self): + try: + self.run_internal() + except Exception as e: + xbmcgui.Dialog().ok(self.addonName, + "A sync thread has exited! " + "You should restart Kodi now. " + "Please report this on the forum.") + raise + def stopThread(self): self._shouldstop.set() @@ -98,9 +109,10 @@ class ThreadedProcessMetadata(threading.Thread): self.itemType = itemType self.userStop = userStop self._shouldstop = threading.Event() + self.addonName = clientinfo.ClientInfo().getAddonName() threading.Thread.__init__(self) - def run(self): + def run_internal(self): # Constructs the method name, e.g. itemtypes.Movies itemFkt = getattr(itemtypes, self.itemType) global processMetadataCount @@ -132,6 +144,16 @@ class ThreadedProcessMetadata(threading.Thread): # signals to queue job is done self.queue.task_done() + def run(self): + try: + self.run_internal() + except Exception as e: + xbmcgui.Dialog().ok(self.addonName, + "A sync thread has exited! " + "You should restart Kodi now. " + "Please report this on the forum.") + raise + def stopThread(self): self._shouldstop.set()