From e37223f0164f0d82ed259b5310c3b92da1777113 Mon Sep 17 00:00:00 2001 From: croneter Date: Fri, 9 Nov 2018 08:44:05 +0100 Subject: [PATCH] Fix full_sync advancing before a section was synced --- resources/lib/backgroundthread.py | 9 +++++++++ resources/lib/library_sync/full_sync.py | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/resources/lib/backgroundthread.py b/resources/lib/backgroundthread.py index ec4db0fa..b4a44327 100644 --- a/resources/lib/backgroundthread.py +++ b/resources/lib/backgroundthread.py @@ -201,17 +201,26 @@ class BackgroundWorker(object): class NonstoppingBackgroundWorker(BackgroundWorker): + def __init__(self, queue, name=None): + self._working = False + super(NonstoppingBackgroundWorker, self).__init__(queue, name) + def _queueLoop(self): LOG.debug('(%s): Active', self.name) while not self.aborted(): try: self._task = self._queue.get_nowait() + self._working = True self._runTask(self._task) + self._working = False self._queue.task_done() self._task = None except Queue.Empty: xbmc.sleep(50) + def working(self): + return self._working + class BackgroundThreader: def __init__(self, name=None, worker=BackgroundWorker, diff --git a/resources/lib/library_sync/full_sync.py b/resources/lib/library_sync/full_sync.py index 2f3e8586..39d5fcff 100644 --- a/resources/lib/library_sync/full_sync.py +++ b/resources/lib/library_sync/full_sync.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, unicode_literals from logging import getLogger +import xbmc from .get_metadata import GetMetadataTask, reset_collections from . import common, process_metadata, sections @@ -117,6 +118,9 @@ class FullSync(common.libsync_mixin): LOG.error('Could not entirely process section %s', section) successful = False continue + LOG.debug('Waiting for download threads to finish') + while self.threader.threader.working(): + xbmc.sleep(100) LOG.debug('Waiting for processing thread to finish section') self.queue.join() reset_collections()