Fix full_sync advancing before a section was synced

This commit is contained in:
croneter 2018-11-09 08:44:05 +01:00
parent c8e8e04697
commit e37223f016
2 changed files with 13 additions and 0 deletions

View file

@ -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,

View file

@ -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()