Ensure Plex companion thread quits on time

This commit is contained in:
croneter 2019-03-17 17:36:56 +01:00
parent 9d07a58c50
commit 815cd20d39

View file

@ -289,7 +289,9 @@ class SubscriptionMgr(object):
# To avoid RuntimeError, don't use self.lastplayers # To avoid RuntimeError, don't use self.lastplayers
for playerid in (0, 1, 2): for playerid in (0, 1, 2):
self.last_params['state'] = 'stopped' self.last_params['state'] = 'stopped'
self._send_pms_notification(playerid, self.last_params) self._send_pms_notification(playerid,
self.last_params,
timeout=0.0001)
def _plex_stream_index(self, playerid, stream_type): def _plex_stream_index(self, playerid, stream_type):
""" """
@ -399,7 +401,11 @@ class SubscriptionMgr(object):
self.last_params = params self.last_params = params
return params return params
def _send_pms_notification(self, playerid, params): def _send_pms_notification(self, playerid, params, timeout=None):
"""
Pass a really low timeout in seconds if shutting down Kodi and we don't
need the PMS' response
"""
serv = self._server_by_host(self.server) serv = self._server_by_host(self.server)
playqueue = PQ.PLAYQUEUES[playerid] playqueue = PQ.PLAYQUEUES[playerid]
xargs = params_pms() xargs = params_pms()
@ -416,7 +422,8 @@ class SubscriptionMgr(object):
DU().downloadUrl(url, DU().downloadUrl(url,
authenticate=False, authenticate=False,
parameters=xargs, parameters=xargs,
headerOverride=HEADERS_PMS) headerOverride=HEADERS_PMS,
timeout=timeout)
LOG.debug("Sent server notification with parameters: %s to %s", LOG.debug("Sent server notification with parameters: %s to %s",
xargs, url) xargs, url)