Fix websocket threads not getting suspended correctly

This commit is contained in:
croneter 2020-05-07 08:37:49 +02:00
parent 5ffcd5782d
commit c34f43cead
4 changed files with 27 additions and 7 deletions

View file

@ -30,3 +30,11 @@ def init(entrypoint=False):
SYNC = Sync(entrypoint) SYNC = Sync(entrypoint)
if not entrypoint: if not entrypoint:
PLAYSTATE = PlayState() PLAYSTATE = PlayState()
def reload():
"""
Reload PKC settings from xml file, e.g. on user-switch
"""
global APP, SYNC
APP.reload()
SYNC.reload()

View file

@ -100,7 +100,6 @@ class Sync(object):
self.artwork = utils.settings('usePlexArtwork') == 'true' self.artwork = utils.settings('usePlexArtwork') == 'true'
self.replace_smb_path = utils.settings('replaceSMB') == 'true' self.replace_smb_path = utils.settings('replaceSMB') == 'true'
self.remap_path = utils.settings('remapSMB') == 'true' self.remap_path = utils.settings('remapSMB') == 'true'
self.force_transcode_pix = utils.settings('force_transcode_pix') == 'true'
self.remapSMBmovieOrg = remove_trailing_slash(utils.settings('remapSMBmovieOrg')) self.remapSMBmovieOrg = remove_trailing_slash(utils.settings('remapSMBmovieOrg'))
self.remapSMBmovieNew = remove_trailing_slash(utils.settings('remapSMBmovieNew')) self.remapSMBmovieNew = remove_trailing_slash(utils.settings('remapSMBmovieNew'))
self.remapSMBtvOrg = remove_trailing_slash(utils.settings('remapSMBtvOrg')) self.remapSMBtvOrg = remove_trailing_slash(utils.settings('remapSMBtvOrg'))
@ -111,7 +110,6 @@ class Sync(object):
self.remapSMBphotoNew = remove_trailing_slash(utils.settings('remapSMBphotoNew')) self.remapSMBphotoNew = remove_trailing_slash(utils.settings('remapSMBphotoNew'))
self.escape_path = utils.settings('escapePath') == 'true' self.escape_path = utils.settings('escapePath') == 'true'
self.indicate_media_versions = utils.settings('indicate_media_versions') == "true" self.indicate_media_versions = utils.settings('indicate_media_versions') == "true"
self.show_extras_instead_of_playing_trailer = utils.settings('showExtrasInsteadOfTrailer') == 'true'
self.sync_specific_plex_playlists = utils.settings('syncSpecificPlexPlaylists') == 'true' self.sync_specific_plex_playlists = utils.settings('syncSpecificPlexPlaylists') == 'true'
self.sync_specific_kodi_playlists = utils.settings('syncSpecificKodiPlaylists') == 'true' self.sync_specific_kodi_playlists = utils.settings('syncSpecificKodiPlaylists') == 'true'
self.sync_thread_number = int(utils.settings('syncThreadNumber')) self.sync_thread_number = int(utils.settings('syncThreadNumber'))
@ -129,3 +127,7 @@ class Sync(object):
self.backgroundsync_saftymargin = int(utils.settings('backgroundsync_saftyMargin')) self.backgroundsync_saftymargin = int(utils.settings('backgroundsync_saftyMargin'))
self.image_sync_notifications = utils.settings('imageSyncNotifications') == 'true' self.image_sync_notifications = utils.settings('imageSyncNotifications') == 'true'
self.force_transcode_pix = utils.settings('force_transcode_pix') == 'true'
# Trailers in Kodi DB will remain UNTIL DB is reset!
self.show_extras_instead_of_playing_trailer = utils.settings('showExtrasInsteadOfTrailer') == 'true'

View file

@ -248,6 +248,7 @@ class Service(object):
icon='{plex}', icon='{plex}',
time=2000, time=2000,
sound=False) sound=False)
app.reload()
app.APP.resume_threads() app.APP.resume_threads()
self.auth_running = False self.auth_running = False

View file

@ -142,9 +142,13 @@ class PMS_Websocket(WebSocket):
""" """
def should_suspend(self): def should_suspend(self):
""" """
Returns True if the thread is suspended Returns True if the thread is suspended.
""" """
return self._suspended or app.SYNC.background_sync_disabled suspend = self._suspended or app.SYNC.background_sync_disabled
if suspend:
# This thread needs to clear the Event() _is_not_suspended itself!
self.suspend()
return suspend
def getUri(self): def getUri(self):
if self.redirect_uri: if self.redirect_uri:
@ -209,9 +213,14 @@ class Alexa_Websocket(WebSocket):
""" """
Overwrite method since we need to check for plex token Overwrite method since we need to check for plex token
""" """
return (self._suspended or suspend = self._suspended or \
not app.ACCOUNT.plex_token or not app.SYNC.enable_alexa or \
app.ACCOUNT.restricted_user) not app.ACCOUNT.plex_token or \
app.ACCOUNT.restricted_user
if suspend:
# This thread needs to clear the Event() _is_not_suspended itself!
self.suspend()
return suspend
def getUri(self): def getUri(self):
if self.redirect_uri: if self.redirect_uri: