Revert "Revert "Try shutting down PKC more cleanly""
This reverts commit a1f1e332b3
.
This commit is contained in:
parent
a63b90dd5f
commit
bce800abc2
2 changed files with 15 additions and 5 deletions
|
@ -14,6 +14,7 @@ from PlexFunctions import scrobble
|
|||
from kodidb_functions import get_kodiid_from_filename
|
||||
from PlexAPI import API
|
||||
from variables import REMAP_TYPE_FROM_PLEXTYPE
|
||||
import state
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -137,6 +138,10 @@ class KodiMonitor(Monitor):
|
|||
sleep(5000)
|
||||
window('plex_runLibScan', value="full")
|
||||
|
||||
elif method == "System.OnQuit":
|
||||
log.info('Kodi OnQuit detected - shutting down')
|
||||
state.STOP_PKC = True
|
||||
|
||||
def PlayBackStart(self, data):
|
||||
"""
|
||||
Called whenever a playback is started
|
||||
|
|
15
service.py
15
service.py
|
@ -133,9 +133,16 @@ class Service():
|
|||
logLevel = 0
|
||||
return logLevel
|
||||
|
||||
def __stop_PKC(self):
|
||||
"""
|
||||
Kodi's abortRequested is really unreliable :-(
|
||||
"""
|
||||
return self.monitor.abortRequested() or state.STOP_PKC
|
||||
|
||||
def ServiceEntryPoint(self):
|
||||
# Important: Threads depending on abortRequest will not trigger
|
||||
# if profile switch happens more than once.
|
||||
__stop_PKC = self.__stop_PKC
|
||||
monitor = self.monitor
|
||||
kodiProfile = v.KODI_PROFILE
|
||||
|
||||
|
@ -161,7 +168,7 @@ class Service():
|
|||
|
||||
welcome_msg = True
|
||||
counter = 0
|
||||
while not monitor.abortRequested():
|
||||
while not __stop_PKC():
|
||||
|
||||
if tryEncode(window('plex_kodiProfile')) != kodiProfile:
|
||||
# Profile change happened, terminate this thread and others
|
||||
|
@ -241,14 +248,13 @@ class Service():
|
|||
# Server went offline
|
||||
break
|
||||
|
||||
if monitor.waitForAbort(5):
|
||||
if monitor.waitForAbort(3):
|
||||
# Abort was requested while waiting. We should exit
|
||||
break
|
||||
sleep(50)
|
||||
else:
|
||||
# Wait until Plex server is online
|
||||
# or Kodi is shut down.
|
||||
while not monitor.abortRequested():
|
||||
while not self.__stop_PKC():
|
||||
server = self.user.getServer()
|
||||
if server is False:
|
||||
# No server info set in add-on settings
|
||||
|
@ -316,7 +322,6 @@ class Service():
|
|||
if monitor.waitForAbort(0.05):
|
||||
# Abort was requested while waiting. We should exit
|
||||
break
|
||||
|
||||
# Terminating PlexKodiConnect
|
||||
|
||||
# Tell all threads to terminate (e.g. several lib sync threads)
|
||||
|
|
Loading…
Reference in a new issue