diff --git a/resources/lib/PlexCompanion.py b/resources/lib/PlexCompanion.py index 93275547..203095f0 100644 --- a/resources/lib/PlexCompanion.py +++ b/resources/lib/PlexCompanion.py @@ -2,7 +2,6 @@ import threading import traceback import socket -import requests import xbmc @@ -103,7 +102,8 @@ class PlexCompanion(threading.Thread): self.client.stop_all() try: httpd.socket.shutdown(socket.SHUT_RDWR) + except: + pass finally: httpd.socket.close() - requests.dumpConnections() self.logMsg("----===## STOP Plex Companion ##===----", 0) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index f8b3d244..aadeca3a 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -148,7 +148,7 @@ def ThreadMethodsAdditionalStop(windowAttribute): def wrapper(cls): def threadStopped(self): return (self._threadStopped or - (window('terminateNow') == "true") or + (window('plex_terminateNow') == "true") or window(windowAttribute) == "true") cls.threadStopped = threadStopped return cls @@ -209,7 +209,7 @@ def ThreadMethods(cls): cls.threadSuspended = threadSuspended def threadStopped(self): - return self._threadStopped or (window('terminateNow') == 'true') + return self._threadStopped or (window('plex_terminateNow') == 'true') cls.threadStopped = threadStopped # Return class to render this a decorator diff --git a/service.py b/service.py index b69a5df0..c3f6041a 100644 --- a/service.py +++ b/service.py @@ -27,6 +27,7 @@ import librarysync import player import utils import videonodes +import downloadutils import PlexAPI import PlexCompanion @@ -82,7 +83,7 @@ class Service(): "plex_authenticated", "EmbyUserImage", "useDirectPaths", "replaceSMB", "remapSMB", "remapSMBmovieOrg", "remapSMBtvOrg", "remapSMBmusicOrg", "remapSMBmovieNew", "remapSMBtvNew", - "remapSMBmusicNew", "suspend_LibraryThread" + "remapSMBmusicNew", "suspend_LibraryThread", "plex_terminateNow" ] for prop in properties: window(prop, clear=True) @@ -282,28 +283,29 @@ class Service(): # Abort was requested while waiting. We should exit break - ##### Emby thread is terminating. ##### + # Terminating PlexKodiConnect - # Tell all threads to terminate - utils.window('terminateNow', value='true') + # Tell all threads to terminate (e.g. several lib sync threads) + utils.window('plex_terminateNow', value='true') try: - if self.plexCompanion_running: - plexCompanion.stopThread() + plexCompanion.stopThread() except: xbmc.log('plexCompanion already shut down') try: - if self.library_running: - library.stopThread() + library.stopThread() except: xbmc.log('Library sync already shut down') - # if self.websocket_running: + downloadutils.DownloadUtils().stopSession() + + # try: # ws.stopClient() + # except: + # xbmc.log('Websocket client already shut down') try: - if self.userclient_running: - user.stopThread() + user.stopThread() except: xbmc.log('User client already shut down')