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