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): class NonstoppingBackgroundWorker(BackgroundWorker):
def __init__(self, queue, name=None):
self._working = False
super(NonstoppingBackgroundWorker, self).__init__(queue, name)
def _queueLoop(self): def _queueLoop(self):
LOG.debug('(%s): Active', self.name) LOG.debug('(%s): Active', self.name)
while not self.aborted(): while not self.aborted():
try: try:
self._task = self._queue.get_nowait() self._task = self._queue.get_nowait()
self._working = True
self._runTask(self._task) self._runTask(self._task)
self._working = False
self._queue.task_done() self._queue.task_done()
self._task = None self._task = None
except Queue.Empty: except Queue.Empty:
xbmc.sleep(50) xbmc.sleep(50)
def working(self):
return self._working
class BackgroundThreader: class BackgroundThreader:
def __init__(self, name=None, worker=BackgroundWorker, def __init__(self, name=None, worker=BackgroundWorker,

View file

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import, division, unicode_literals from __future__ import absolute_import, division, unicode_literals
from logging import getLogger from logging import getLogger
import xbmc
from .get_metadata import GetMetadataTask, reset_collections from .get_metadata import GetMetadataTask, reset_collections
from . import common, process_metadata, sections from . import common, process_metadata, sections
@ -117,6 +118,9 @@ class FullSync(common.libsync_mixin):
LOG.error('Could not entirely process section %s', section) LOG.error('Could not entirely process section %s', section)
successful = False successful = False
continue 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') LOG.debug('Waiting for processing thread to finish section')
self.queue.join() self.queue.join()
reset_collections() reset_collections()