Get section iterators in a dedicated thread to gain speed
This commit is contained in:
parent
0d537f108e
commit
654748218e
1 changed files with 12 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue