From 5c7968abdb77a284956ef280f6e9c150a5432d81 Mon Sep 17 00:00:00 2001 From: croneter Date: Tue, 13 Nov 2018 15:01:31 +0100 Subject: [PATCH] Ensure that fanart sync closes DB connection during playback --- resources/lib/library_sync/fanart.py | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/resources/lib/library_sync/fanart.py b/resources/lib/library_sync/fanart.py index 3963aead..cc6f1532 100644 --- a/resources/lib/library_sync/fanart.py +++ b/resources/lib/library_sync/fanart.py @@ -44,17 +44,24 @@ class FanartThread(backgroundthread.KillableThread): def _run_internal(self): LOG.info('Starting FanartThread') - with PlexDB() as plexdb: - func = plexdb.every_plex_id if self.refresh else plexdb.missing_fanart - for typus in SUPPORTED_TYPES: - for plex_id in func(typus): - if self.isCanceled(): - return - if self.isSuspended(): - if self.isCanceled(): - return - xbmc.sleep(1000) - process_fanart(plex_id, typus, self.refresh) + while True: + with PlexDB() as plexdb: + func = plexdb.every_plex_id if self.refresh else plexdb.missing_fanart + for typus in SUPPORTED_TYPES: + for plex_id in func(typus): + if self.isCanceled() or self.isSuspended(): + break + process_fanart(plex_id, typus, self.refresh) + else: + # Done processing! + break + # Need to have these outside our DB context to close the connection + if self.isCanceled(): + return + if self.isSuspended(): + if self.isCanceled(): + return + xbmc.sleep(1000) LOG.info('FanartThread finished') self.callback()