diff --git a/resources/lib/library_sync/full_sync.py b/resources/lib/library_sync/full_sync.py index 692f620c..4e2571d7 100644 --- a/resources/lib/library_sync/full_sync.py +++ b/resources/lib/library_sync/full_sync.py @@ -147,11 +147,11 @@ class FullSync(common.LibrarySyncMixin, backgroundthread.KillableThread): LOG.error('Could not entirely process section %s', section) self.successful = False - def get_generators(self, kinds, queue, all_items): + def threaded_get_generators(self, kinds, queue, all_items): """ - Getting iterators is costly, so let's do it asynchronously + Getting iterators is costly, so let's do it in a dedicated thread """ - LOG.debug('Start get_generators') + LOG.debug('Start threaded_get_generators') try: for kind in kinds: for section in (x for x in app.SYNC.sections @@ -189,7 +189,7 @@ class FullSync(common.LibrarySyncMixin, backgroundthread.KillableThread): utils.ERROR(notify=True) finally: queue.put(None) - LOG.debug('Exiting get_generators') + LOG.debug('Exiting threaded_get_generators') def full_library_sync(self): kinds = [ @@ -205,7 +205,10 @@ class FullSync(common.LibrarySyncMixin, backgroundthread.KillableThread): ]) # ADD NEW ITEMS # We need to enforce syncing e.g. show before season before episode - self.get_generators(kinds, self.section_queue, False) + thread = backgroundthread.KillableThread( + target=self.threaded_get_generators, + args=(kinds, self.section_queue, False)) + thread.start() # Do the heavy lifting self.processing_loop_new_and_changed_items() common.update_kodi_library(video=True, music=True) @@ -237,7 +240,10 @@ class FullSync(common.LibrarySyncMixin, backgroundthread.KillableThread): # Close the progress indicator dialog self.dialog.close() self.dialog = None - self.get_generators(kinds, self.section_queue, True) + thread = backgroundthread.KillableThread( + target=self.threaded_get_generators, + args=(kinds, self.section_queue, True)) + thread.start() self.processing_loop_playstates() if self.should_cancel() or not self.successful: return