Enable library sync threads to crash correctly

This commit is contained in:
tomkat83 2016-01-15 08:53:16 +01:00
parent 40c02395a2
commit 0f73bf1840

View file

@ -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()