Rename thread methods
This commit is contained in:
parent
5068327408
commit
e02e9bcd1f
13 changed files with 82 additions and 83 deletions
|
@ -221,8 +221,8 @@ class PlexCompanion(Thread):
|
||||||
httpd = self.httpd
|
httpd = self.httpd
|
||||||
# Cache for quicker while loops
|
# Cache for quicker while loops
|
||||||
client = self.client
|
client = self.client
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
thread_suspended = self.thread_suspended
|
suspended = self.suspended
|
||||||
|
|
||||||
# Start up instances
|
# Start up instances
|
||||||
request_mgr = httppersist.RequestMgr()
|
request_mgr = httppersist.RequestMgr()
|
||||||
|
@ -259,12 +259,12 @@ class PlexCompanion(Thread):
|
||||||
if httpd:
|
if httpd:
|
||||||
thread = Thread(target=httpd.handle_request)
|
thread = Thread(target=httpd.handle_request)
|
||||||
|
|
||||||
while not thread_stopped():
|
while not stopped():
|
||||||
# If we are not authorized, sleep
|
# If we are not authorized, sleep
|
||||||
# Otherwise, we trigger a download which leads to a
|
# Otherwise, we trigger a download which leads to a
|
||||||
# re-authorizations
|
# re-authorizations
|
||||||
while thread_suspended():
|
while suspended():
|
||||||
if thread_stopped():
|
if stopped():
|
||||||
break
|
break
|
||||||
sleep(1000)
|
sleep(1000)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -50,15 +50,15 @@ class Image_Cache_Thread(Thread):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
thread_suspended = self.thread_suspended
|
suspended = self.suspended
|
||||||
queue = self.queue
|
queue = self.queue
|
||||||
sleep_between = self.sleep_between
|
sleep_between = self.sleep_between
|
||||||
while not thread_stopped():
|
while not stopped():
|
||||||
# In the event the server goes offline
|
# In the event the server goes offline
|
||||||
while thread_suspended():
|
while suspended():
|
||||||
# Set in service.py
|
# Set in service.py
|
||||||
if thread_stopped():
|
if stopped():
|
||||||
# Abort was requested while waiting. We should exit
|
# Abort was requested while waiting. We should exit
|
||||||
LOG.info("---===### Stopped Image_Cache_Thread ###===---")
|
LOG.info("---===### Stopped Image_Cache_Thread ###===---")
|
||||||
return
|
return
|
||||||
|
@ -84,7 +84,7 @@ class Image_Cache_Thread(Thread):
|
||||||
# download. All is well
|
# download. All is well
|
||||||
break
|
break
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
if thread_stopped():
|
if stopped():
|
||||||
# Kodi terminated
|
# Kodi terminated
|
||||||
break
|
break
|
||||||
# Server thinks its a DOS attack, ('error 10053')
|
# Server thinks its a DOS attack, ('error 10053')
|
||||||
|
|
|
@ -22,10 +22,10 @@ class Monitor_Window(Thread):
|
||||||
Adjusts state.py accordingly
|
Adjusts state.py accordingly
|
||||||
"""
|
"""
|
||||||
def run(self):
|
def run(self):
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
queue = state.COMMAND_PIPELINE_QUEUE
|
queue = state.COMMAND_PIPELINE_QUEUE
|
||||||
LOG.info("----===## Starting Kodi_Play_Client ##===----")
|
LOG.info("----===## Starting Kodi_Play_Client ##===----")
|
||||||
while not thread_stopped():
|
while not stopped():
|
||||||
if window('plex_command'):
|
if window('plex_command'):
|
||||||
value = window('plex_command')
|
value = window('plex_command')
|
||||||
window('plex_command', clear=True)
|
window('plex_command', clear=True)
|
||||||
|
|
|
@ -400,7 +400,7 @@ class SpecialMonitor(Thread):
|
||||||
LOG.info("----====# Starting Special Monitor #====----")
|
LOG.info("----====# Starting Special Monitor #====----")
|
||||||
# "Start from beginning", "Play from beginning"
|
# "Start from beginning", "Play from beginning"
|
||||||
strings = (getLocalizedString(12021), getLocalizedString(12023))
|
strings = (getLocalizedString(12021), getLocalizedString(12023))
|
||||||
while not self.thread_stopped():
|
while not self.stopped():
|
||||||
if (getCondVisibility('Window.IsVisible(DialogContextMenu.xml)') and
|
if (getCondVisibility('Window.IsVisible(DialogContextMenu.xml)') and
|
||||||
getInfoLabel('Control.GetLabel(1002)') in strings):
|
getInfoLabel('Control.GetLabel(1002)') in strings):
|
||||||
# Remember that the item IS indeed resumable
|
# Remember that the item IS indeed resumable
|
||||||
|
|
|
@ -54,14 +54,14 @@ class Process_Fanart_Thread(Thread):
|
||||||
Do the work
|
Do the work
|
||||||
"""
|
"""
|
||||||
log.debug("---===### Starting FanartSync ###===---")
|
log.debug("---===### Starting FanartSync ###===---")
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
thread_suspended = self.thread_suspended
|
suspended = self.suspended
|
||||||
queue = self.queue
|
queue = self.queue
|
||||||
while not thread_stopped():
|
while not stopped():
|
||||||
# In the event the server goes offline
|
# In the event the server goes offline
|
||||||
while thread_suspended():
|
while suspended():
|
||||||
# Set in service.py
|
# Set in service.py
|
||||||
if thread_stopped():
|
if stopped():
|
||||||
# Abort was requested while waiting. We should exit
|
# Abort was requested while waiting. We should exit
|
||||||
log.info("---===### Stopped FanartSync ###===---")
|
log.info("---===### Stopped FanartSync ###===---")
|
||||||
return
|
return
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Threaded_Get_Metadata(Thread):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
if self.thread_stopped():
|
if self.stopped():
|
||||||
# Shutdown from outside requested; purge out_queue as well
|
# Shutdown from outside requested; purge out_queue as well
|
||||||
while not self.out_queue.empty():
|
while not self.out_queue.empty():
|
||||||
# Still try because remaining item might have been taken
|
# Still try because remaining item might have been taken
|
||||||
|
@ -78,8 +78,8 @@ class Threaded_Get_Metadata(Thread):
|
||||||
# cache local variables because it's faster
|
# cache local variables because it's faster
|
||||||
queue = self.queue
|
queue = self.queue
|
||||||
out_queue = self.out_queue
|
out_queue = self.out_queue
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
while thread_stopped() is False:
|
while stopped() is False:
|
||||||
# grabs Plex item from queue
|
# grabs Plex item from queue
|
||||||
try:
|
try:
|
||||||
item = queue.get(block=False)
|
item = queue.get(block=False)
|
||||||
|
|
|
@ -68,9 +68,9 @@ class Threaded_Process_Metadata(Thread):
|
||||||
item_fct = getattr(itemtypes, self.item_type)
|
item_fct = getattr(itemtypes, self.item_type)
|
||||||
# cache local variables because it's faster
|
# cache local variables because it's faster
|
||||||
queue = self.queue
|
queue = self.queue
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
with item_fct() as item_class:
|
with item_fct() as item_class:
|
||||||
while thread_stopped() is False:
|
while stopped() is False:
|
||||||
# grabs item from queue
|
# grabs item from queue
|
||||||
try:
|
try:
|
||||||
item = queue.get(block=False)
|
item = queue.get(block=False)
|
||||||
|
|
|
@ -52,14 +52,13 @@ class Threaded_Show_Sync_Info(Thread):
|
||||||
# cache local variables because it's faster
|
# cache local variables because it's faster
|
||||||
total = self.total
|
total = self.total
|
||||||
dialog = DialogProgressBG('dialoglogProgressBG')
|
dialog = DialogProgressBG('dialoglogProgressBG')
|
||||||
thread_stopped = self.thread_stopped
|
|
||||||
dialog.create("%s %s: %s %s"
|
dialog.create("%s %s: %s %s"
|
||||||
% (lang(39714), self.item_type, str(total), lang(39715)))
|
% (lang(39714), self.item_type, str(total), lang(39715)))
|
||||||
player = Player()
|
player = Player()
|
||||||
|
|
||||||
total = 2 * total
|
total = 2 * total
|
||||||
totalProgress = 0
|
totalProgress = 0
|
||||||
while thread_stopped() is False and not player.isPlaying():
|
while self.stopped() is False and not player.isPlaying():
|
||||||
with LOCK:
|
with LOCK:
|
||||||
get_progress = GET_METADATA_COUNT
|
get_progress = GET_METADATA_COUNT
|
||||||
process_progress = PROCESS_METADATA_COUNT
|
process_progress = PROCESS_METADATA_COUNT
|
||||||
|
|
|
@ -262,8 +262,8 @@ class LibrarySync(Thread):
|
||||||
|
|
||||||
# Do the processing
|
# Do the processing
|
||||||
for itemtype in process:
|
for itemtype in process:
|
||||||
if (self.thread_stopped() or
|
if (self.stopped() or
|
||||||
self.thread_suspended() or
|
self.suspended() or
|
||||||
not process[itemtype]()):
|
not process[itemtype]()):
|
||||||
xbmc.executebuiltin('InhibitIdleShutdown(false)')
|
xbmc.executebuiltin('InhibitIdleShutdown(false)')
|
||||||
js.set_setting('screensaver.mode', screensaver)
|
js.set_setting('screensaver.mode', screensaver)
|
||||||
|
@ -705,7 +705,7 @@ class LibrarySync(Thread):
|
||||||
for thread in threads:
|
for thread in threads:
|
||||||
# Threads might already have quit by themselves (e.g. Kodi exit)
|
# Threads might already have quit by themselves (e.g. Kodi exit)
|
||||||
try:
|
try:
|
||||||
thread.stop_thread()
|
thread.stop()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
log.debug("Stop sent to all threads")
|
log.debug("Stop sent to all threads")
|
||||||
|
@ -753,7 +753,7 @@ class LibrarySync(Thread):
|
||||||
for view in views:
|
for view in views:
|
||||||
if self.installSyncDone is not True:
|
if self.installSyncDone is not True:
|
||||||
state.PATH_VERIFIED = False
|
state.PATH_VERIFIED = False
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
return False
|
return False
|
||||||
# Get items per view
|
# Get items per view
|
||||||
viewId = view['id']
|
viewId = view['id']
|
||||||
|
@ -773,7 +773,7 @@ class LibrarySync(Thread):
|
||||||
self.GetAndProcessXMLs(itemType)
|
self.GetAndProcessXMLs(itemType)
|
||||||
# Update viewstate for EVERY item
|
# Update viewstate for EVERY item
|
||||||
for view in views:
|
for view in views:
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
return False
|
return False
|
||||||
self.PlexUpdateWatched(view['id'], itemType)
|
self.PlexUpdateWatched(view['id'], itemType)
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ class LibrarySync(Thread):
|
||||||
for view in views:
|
for view in views:
|
||||||
if self.installSyncDone is not True:
|
if self.installSyncDone is not True:
|
||||||
state.PATH_VERIFIED = False
|
state.PATH_VERIFIED = False
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
return False
|
return False
|
||||||
# Get items per view
|
# Get items per view
|
||||||
viewId = view['id']
|
viewId = view['id']
|
||||||
|
@ -876,7 +876,7 @@ class LibrarySync(Thread):
|
||||||
# PROCESS TV Seasons #####
|
# PROCESS TV Seasons #####
|
||||||
# Cycle through tv shows
|
# Cycle through tv shows
|
||||||
for tvShowId in allPlexTvShowsId:
|
for tvShowId in allPlexTvShowsId:
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
return False
|
return False
|
||||||
# Grab all seasons to tvshow from PMS
|
# Grab all seasons to tvshow from PMS
|
||||||
seasons = GetAllPlexChildren(tvShowId)
|
seasons = GetAllPlexChildren(tvShowId)
|
||||||
|
@ -901,7 +901,7 @@ class LibrarySync(Thread):
|
||||||
# PROCESS TV Episodes #####
|
# PROCESS TV Episodes #####
|
||||||
# Cycle through tv shows
|
# Cycle through tv shows
|
||||||
for view in views:
|
for view in views:
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
return False
|
return False
|
||||||
# Grab all episodes to tvshow from PMS
|
# Grab all episodes to tvshow from PMS
|
||||||
episodes = GetAllPlexLeaves(view['id'])
|
episodes = GetAllPlexLeaves(view['id'])
|
||||||
|
@ -936,7 +936,7 @@ class LibrarySync(Thread):
|
||||||
|
|
||||||
# Update viewstate:
|
# Update viewstate:
|
||||||
for view in views:
|
for view in views:
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
return False
|
return False
|
||||||
self.PlexUpdateWatched(view['id'], itemType)
|
self.PlexUpdateWatched(view['id'], itemType)
|
||||||
|
|
||||||
|
@ -973,7 +973,7 @@ class LibrarySync(Thread):
|
||||||
for kind in (v.PLEX_TYPE_ARTIST,
|
for kind in (v.PLEX_TYPE_ARTIST,
|
||||||
v.PLEX_TYPE_ALBUM,
|
v.PLEX_TYPE_ALBUM,
|
||||||
v.PLEX_TYPE_SONG):
|
v.PLEX_TYPE_SONG):
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
return False
|
return False
|
||||||
log.debug("Start processing music %s" % kind)
|
log.debug("Start processing music %s" % kind)
|
||||||
self.allKodiElementsId = {}
|
self.allKodiElementsId = {}
|
||||||
|
@ -990,7 +990,7 @@ class LibrarySync(Thread):
|
||||||
|
|
||||||
# Update viewstate for EVERY item
|
# Update viewstate for EVERY item
|
||||||
for view in views:
|
for view in views:
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
return False
|
return False
|
||||||
self.PlexUpdateWatched(view['id'], itemType)
|
self.PlexUpdateWatched(view['id'], itemType)
|
||||||
|
|
||||||
|
@ -1017,7 +1017,7 @@ class LibrarySync(Thread):
|
||||||
for view in views:
|
for view in views:
|
||||||
if self.installSyncDone is not True:
|
if self.installSyncDone is not True:
|
||||||
state.PATH_VERIFIED = False
|
state.PATH_VERIFIED = False
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
return False
|
return False
|
||||||
# Get items per view
|
# Get items per view
|
||||||
itemsXML = GetPlexSectionResults(view['id'], args=urlArgs)
|
itemsXML = GetPlexSectionResults(view['id'], args=urlArgs)
|
||||||
|
@ -1105,7 +1105,7 @@ class LibrarySync(Thread):
|
||||||
now = unix_timestamp()
|
now = unix_timestamp()
|
||||||
deleteListe = []
|
deleteListe = []
|
||||||
for i, item in enumerate(self.itemsToProcess):
|
for i, item in enumerate(self.itemsToProcess):
|
||||||
if self.thread_stopped() or self.thread_suspended():
|
if self.stopped() or self.suspended():
|
||||||
# Chances are that Kodi gets shut down
|
# Chances are that Kodi gets shut down
|
||||||
break
|
break
|
||||||
if item['state'] == 9:
|
if item['state'] == 9:
|
||||||
|
@ -1484,8 +1484,8 @@ class LibrarySync(Thread):
|
||||||
|
|
||||||
def run_internal(self):
|
def run_internal(self):
|
||||||
# Re-assign handles to have faster calls
|
# Re-assign handles to have faster calls
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
thread_suspended = self.thread_suspended
|
suspended = self.suspended
|
||||||
installSyncDone = self.installSyncDone
|
installSyncDone = self.installSyncDone
|
||||||
background_sync = state.BACKGROUND_SYNC
|
background_sync = state.BACKGROUND_SYNC
|
||||||
fullSync = self.fullSync
|
fullSync = self.fullSync
|
||||||
|
@ -1511,12 +1511,12 @@ class LibrarySync(Thread):
|
||||||
if settings('FanartTV') == 'true':
|
if settings('FanartTV') == 'true':
|
||||||
self.fanartthread.start()
|
self.fanartthread.start()
|
||||||
|
|
||||||
while not thread_stopped():
|
while not stopped():
|
||||||
|
|
||||||
# In the event the server goes offline
|
# In the event the server goes offline
|
||||||
while thread_suspended():
|
while suspended():
|
||||||
# Set in service.py
|
# Set in service.py
|
||||||
if thread_stopped():
|
if stopped():
|
||||||
# Abort was requested while waiting. We should exit
|
# Abort was requested while waiting. We should exit
|
||||||
log.info("###===--- LibrarySync Stopped ---===###")
|
log.info("###===--- LibrarySync Stopped ---===###")
|
||||||
return
|
return
|
||||||
|
@ -1613,7 +1613,7 @@ class LibrarySync(Thread):
|
||||||
log.info('Doing scheduled full library scan')
|
log.info('Doing scheduled full library scan')
|
||||||
state.DB_SCAN = True
|
state.DB_SCAN = True
|
||||||
window('plex_dbScan', value="true")
|
window('plex_dbScan', value="true")
|
||||||
if fullSync() is False and not thread_stopped():
|
if fullSync() is False and not stopped():
|
||||||
log.error('Could not finish scheduled full sync')
|
log.error('Could not finish scheduled full sync')
|
||||||
self.force_dialog = True
|
self.force_dialog = True
|
||||||
self.showKodiNote(lang(39410),
|
self.showKodiNote(lang(39410),
|
||||||
|
|
|
@ -149,7 +149,7 @@ class PlayqueueMonitor(Thread):
|
||||||
# Ignore new media added by other addons
|
# Ignore new media added by other addons
|
||||||
continue
|
continue
|
||||||
for j, old_item in enumerate(old):
|
for j, old_item in enumerate(old):
|
||||||
if self.thread_stopped():
|
if self.stopped():
|
||||||
# Chances are that we got an empty Kodi playlist due to
|
# Chances are that we got an empty Kodi playlist due to
|
||||||
# Kodi exit
|
# Kodi exit
|
||||||
return
|
return
|
||||||
|
@ -194,7 +194,7 @@ class PlayqueueMonitor(Thread):
|
||||||
for j in range(i, len(index)):
|
for j in range(i, len(index)):
|
||||||
index[j] += 1
|
index[j] += 1
|
||||||
for i in reversed(index):
|
for i in reversed(index):
|
||||||
if self.thread_stopped():
|
if self.stopped():
|
||||||
# Chances are that we got an empty Kodi playlist due to
|
# Chances are that we got an empty Kodi playlist due to
|
||||||
# Kodi exit
|
# Kodi exit
|
||||||
return
|
return
|
||||||
|
@ -203,12 +203,12 @@ class PlayqueueMonitor(Thread):
|
||||||
LOG.debug('Done comparing playqueues')
|
LOG.debug('Done comparing playqueues')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
thread_suspended = self.thread_suspended
|
suspended = self.suspended
|
||||||
LOG.info("----===## Starting PlayqueueMonitor ##===----")
|
LOG.info("----===## Starting PlayqueueMonitor ##===----")
|
||||||
while not thread_stopped():
|
while not stopped():
|
||||||
while thread_suspended():
|
while suspended():
|
||||||
if thread_stopped():
|
if stopped():
|
||||||
break
|
break
|
||||||
sleep(1000)
|
sleep(1000)
|
||||||
with LOCK:
|
with LOCK:
|
||||||
|
|
|
@ -287,11 +287,11 @@ class UserClient(Thread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
LOG.info("----===## Starting UserClient ##===----")
|
LOG.info("----===## Starting UserClient ##===----")
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
thread_suspended = self.thread_suspended
|
suspended = self.suspended
|
||||||
while not thread_stopped():
|
while not stopped():
|
||||||
while thread_suspended():
|
while suspended():
|
||||||
if thread_stopped():
|
if stopped():
|
||||||
break
|
break
|
||||||
sleep(1000)
|
sleep(1000)
|
||||||
|
|
||||||
|
|
|
@ -1004,13 +1004,13 @@ def thread_methods(cls=None, add_stops=None, add_suspends=None):
|
||||||
"""
|
"""
|
||||||
Decorator to add the following methods to a threading class:
|
Decorator to add the following methods to a threading class:
|
||||||
|
|
||||||
suspend_thread(): pauses the thread
|
suspend(): pauses the thread
|
||||||
resume_thread(): resumes the thread
|
resume(): resumes the thread
|
||||||
stop_thread(): stopps/kills the thread
|
stop(): stopps/kills the thread
|
||||||
|
|
||||||
thread_suspended(): returns True if thread is suspended
|
suspended(): returns True if thread is suspended
|
||||||
thread_stopped(): returns True if thread is stopped (or should stop ;-))
|
stopped(): returns True if thread is stopped (or should stop ;-))
|
||||||
ALSO returns True if PKC should exit
|
ALSO returns True if PKC should exit
|
||||||
|
|
||||||
Also adds the following class attributes:
|
Also adds the following class attributes:
|
||||||
thread_stopped
|
thread_stopped
|
||||||
|
@ -1043,28 +1043,28 @@ def thread_methods(cls=None, add_stops=None, add_suspends=None):
|
||||||
cls.thread_suspended = False
|
cls.thread_suspended = False
|
||||||
|
|
||||||
# Define new class methods and attach them to class
|
# Define new class methods and attach them to class
|
||||||
def stop_thread(self):
|
def stop(self):
|
||||||
"""
|
"""
|
||||||
Call to stop this thread
|
Call to stop this thread
|
||||||
"""
|
"""
|
||||||
self.thread_stopped = True
|
self.thread_stopped = True
|
||||||
cls.stop_thread = stop_thread
|
cls.stop = stop
|
||||||
|
|
||||||
def suspend_thread(self):
|
def suspend(self):
|
||||||
"""
|
"""
|
||||||
Call to suspend this thread
|
Call to suspend this thread
|
||||||
"""
|
"""
|
||||||
self.thread_suspended = True
|
self.thread_suspended = True
|
||||||
cls.suspend_thread = suspend_thread
|
cls.suspend = suspend
|
||||||
|
|
||||||
def resume_thread(self):
|
def resume(self):
|
||||||
"""
|
"""
|
||||||
Call to revive a suspended thread back to life
|
Call to revive a suspended thread back to life
|
||||||
"""
|
"""
|
||||||
self.thread_suspended = False
|
self.thread_suspended = False
|
||||||
cls.resume_thread = resume_thread
|
cls.resume = resume
|
||||||
|
|
||||||
def thread_suspended(self):
|
def suspended(self):
|
||||||
"""
|
"""
|
||||||
Returns True if the thread is suspended
|
Returns True if the thread is suspended
|
||||||
"""
|
"""
|
||||||
|
@ -1074,9 +1074,9 @@ def thread_methods(cls=None, add_stops=None, add_suspends=None):
|
||||||
if getattr(state, suspend):
|
if getattr(state, suspend):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
cls.thread_suspended = thread_suspended
|
cls.suspended = suspended
|
||||||
|
|
||||||
def thread_stopped(self):
|
def stopped(self):
|
||||||
"""
|
"""
|
||||||
Returns True if the thread is stopped
|
Returns True if the thread is stopped
|
||||||
"""
|
"""
|
||||||
|
@ -1086,7 +1086,7 @@ def thread_methods(cls=None, add_stops=None, add_suspends=None):
|
||||||
if getattr(state, stop):
|
if getattr(state, stop):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
cls.thread_stopped = thread_stopped
|
cls.stopped = stopped
|
||||||
|
|
||||||
# Return class to render this a decorator
|
# Return class to render this a decorator
|
||||||
return cls
|
return cls
|
||||||
|
|
|
@ -58,16 +58,16 @@ class WebSocket(Thread):
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
handshake_counter = 0
|
handshake_counter = 0
|
||||||
thread_stopped = self.thread_stopped
|
stopped = self.stopped
|
||||||
thread_suspended = self.thread_suspended
|
suspended = self.suspended
|
||||||
while not thread_stopped():
|
while not stopped():
|
||||||
# In the event the server goes offline
|
# In the event the server goes offline
|
||||||
while thread_suspended():
|
while suspended():
|
||||||
# Set in service.py
|
# Set in service.py
|
||||||
if self.ws is not None:
|
if self.ws is not None:
|
||||||
self.ws.close()
|
self.ws.close()
|
||||||
self.ws = None
|
self.ws = None
|
||||||
if thread_stopped():
|
if stopped():
|
||||||
# Abort was requested while waiting. We should exit
|
# Abort was requested while waiting. We should exit
|
||||||
LOG.info("##===---- %s Stopped ----===##",
|
LOG.info("##===---- %s Stopped ----===##",
|
||||||
self.__class__.__name__)
|
self.__class__.__name__)
|
||||||
|
@ -255,16 +255,16 @@ class Alexa_Websocket(WebSocket):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Path in thread_methods
|
# Path in thread_methods
|
||||||
def stop_thread(self):
|
def stop(self):
|
||||||
self.thread_stopped = True
|
self.thread_stopped = True
|
||||||
|
|
||||||
def suspend_thread(self):
|
def suspend(self):
|
||||||
self.thread_suspended = True
|
self.thread_suspended = True
|
||||||
|
|
||||||
def resume_thread(self):
|
def resume(self):
|
||||||
self.thread_suspended = False
|
self.thread_suspended = False
|
||||||
|
|
||||||
def thread_stopped(self):
|
def stopped(self):
|
||||||
if self.thread_stopped is True:
|
if self.thread_stopped is True:
|
||||||
return True
|
return True
|
||||||
if state.STOP_PKC:
|
if state.STOP_PKC:
|
||||||
|
@ -272,7 +272,7 @@ class Alexa_Websocket(WebSocket):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# The culprit
|
# The culprit
|
||||||
def thread_suspended(self):
|
def suspended(self):
|
||||||
"""
|
"""
|
||||||
Overwrite method since we need to check for plex token
|
Overwrite method since we need to check for plex token
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue