Change thread stops to use window property instead of xbmc monitor
This commit is contained in:
parent
300b5d11ad
commit
c9d8d8d5c6
2 changed files with 21 additions and 12 deletions
|
@ -49,7 +49,7 @@ def ThreadMethodsAdditionalStop(windowAttribute):
|
|||
def wrapper(cls):
|
||||
def threadStopped(self):
|
||||
return (self._threadStopped or
|
||||
self._abortMonitor.abortRequested() or
|
||||
(window('terminateNow') == "true") or
|
||||
window(windowAttribute) == "true")
|
||||
cls.threadStopped = threadStopped
|
||||
return cls
|
||||
|
@ -78,7 +78,7 @@ def ThreadMethods(cls):
|
|||
|
||||
suspendThread(): pauses the thread
|
||||
resumeThread(): resumes the thread
|
||||
stopThread(): stopps the thread
|
||||
stopThread(): stopps/kills the thread
|
||||
|
||||
threadSuspended(): returns True if thread is suspend_thread
|
||||
threadStopped(): returns True if thread is stopped (or should stop ;-))
|
||||
|
@ -87,12 +87,10 @@ def ThreadMethods(cls):
|
|||
Also adds the following class attributes:
|
||||
_threadStopped
|
||||
_threadSuspended
|
||||
_abortMonitor = xbmc.Monitor() (to check for premature Kodi exit)
|
||||
"""
|
||||
# Attach new attributes to class
|
||||
cls._threadStopped = False
|
||||
cls._threadSuspended = False
|
||||
cls._abortMonitor = xbmc.Monitor()
|
||||
|
||||
# Define new class methods and attach them to class
|
||||
def stopThread(self):
|
||||
|
@ -112,7 +110,7 @@ def ThreadMethods(cls):
|
|||
cls.threadSuspended = threadSuspended
|
||||
|
||||
def threadStopped(self):
|
||||
return self._threadStopped or self._abortMonitor.abortRequested()
|
||||
return self._threadStopped or (window('terminateNow') == 'true')
|
||||
cls.threadStopped = threadStopped
|
||||
|
||||
# Return class to render this a decorator
|
||||
|
|
25
service.py
25
service.py
|
@ -293,17 +293,28 @@ class Service():
|
|||
|
||||
##### Emby thread is terminating. #####
|
||||
|
||||
if self.plexCompanion_running:
|
||||
plexCompanion.stopThread()
|
||||
# Tell all threads to terminate
|
||||
utils.window('terminateNow', value='true')
|
||||
|
||||
if self.library_running:
|
||||
library.stopThread()
|
||||
try:
|
||||
if self.plexCompanion_running:
|
||||
plexCompanion.stopThread()
|
||||
except:
|
||||
xbmc.log('plexCompanion already shut down')
|
||||
|
||||
try:
|
||||
if self.library_running:
|
||||
library.stopThread()
|
||||
except:
|
||||
xbmc.log('Library sync already shut down')
|
||||
|
||||
# if self.websocket_running:
|
||||
# ws.stopClient()
|
||||
|
||||
if self.userclient_running:
|
||||
user.stopThread()
|
||||
try:
|
||||
if self.userclient_running:
|
||||
user.stopThread()
|
||||
except:
|
||||
xbmc.log('User client already shut down')
|
||||
|
||||
log("======== STOP %s ========" % self.addonName, 0)
|
||||
|
||||
|
|
Loading…
Reference in a new issue