-retry start() on threads as slow systems can sometimes take a few seconds to release old threads

-check json parsing for errros and return
-if no runtime then use zero
This commit is contained in:
shaun 2017-01-07 19:19:39 +11:00
parent 4298db5f90
commit 00edbf610b
3 changed files with 29 additions and 7 deletions

View file

@ -64,8 +64,12 @@ class KodiMonitor(xbmc.Monitor):
if method not in ('Playlist.OnAdd', 'Player.OnStop', 'Player.OnClear'): if method not in ('Playlist.OnAdd', 'Player.OnStop', 'Player.OnClear'):
log.info("Method: %s Data: %s", method, data) log.info("Method: %s Data: %s", method, data)
try:
if data: if data:
data = json.loads(data, 'utf-8') data = json.loads(data, 'utf-8')
except:
log.info("Error parsing message data: %s", data)
return
if method == 'Player.OnPlay': if method == 'Player.OnPlay':
self._on_play_(data) self._on_play_(data)

View file

@ -215,8 +215,12 @@ class Player(xbmc.Player):
try: try:
runtime = int(runtime) runtime = int(runtime)
except ValueError: except ValueError:
runtime = self.xbmcplayer.getTotalTime() try:
runtime = int(self.xbmcplayer.getTotalTime())
log.info("Runtime is missing, Kodi runtime: %s" % runtime) log.info("Runtime is missing, Kodi runtime: %s" % runtime)
except:
runtime = 0
log.info("Runtime is missing, Using Zero")
# Save data map for updates and position calls # Save data map for updates and position calls
data = { data = {

View file

@ -82,9 +82,23 @@ class Read_EmbyServer():
if len(self.download_threads) < self.download_limit: if len(self.download_threads) < self.download_limit:
# Start new "daemon thread" - actual daemon thread is not supported in Kodi # Start new "daemon thread" - actual daemon thread is not supported in Kodi
new_thread = DownloadThreader(queue, output) new_thread = DownloadThreader(queue, output)
counter = 0
worked = False
while counter < 10:
try:
new_thread.start() new_thread.start()
worked = True
break
except:
counter = counter + 1
xbmc.sleep(1000)
if worked:
self.download_threads.append(new_thread) self.download_threads.append(new_thread)
return True return True
else:
return False
else: else:
log.info("Waiting for empty download spot: %s", len(self.download_threads)) log.info("Waiting for empty download spot: %s", len(self.download_threads))
xbmc.sleep(100) xbmc.sleep(100)