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