Shut down PKC correctly
This commit is contained in:
parent
feb01b748f
commit
d8deb4919e
3 changed files with 17 additions and 15 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
24
service.py
24
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')
|
||||
|
||||
|
|
Loading…
Reference in a new issue