From 7830a0e0e3159eaf9f97a3f00e4baf8f360f2c74 Mon Sep 17 00:00:00 2001 From: croneter Date: Fri, 9 Nov 2018 08:56:57 +0100 Subject: [PATCH] Let full_sync finish gracefully on Kodi exit --- resources/lib/library_sync/get_metadata.py | 3 ++- resources/lib/library_sync/process_metadata.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/lib/library_sync/get_metadata.py b/resources/lib/library_sync/get_metadata.py index 4de1388d..d8d90d05 100644 --- a/resources/lib/library_sync/get_metadata.py +++ b/resources/lib/library_sync/get_metadata.py @@ -118,4 +118,5 @@ class GetMetadataTask(backgroundthread.Task, common.libsync_mixin): self.plex_id) else: item['children'] = children_xml - self.queue.put(item) + if not self.isCanceled(): + self.queue.put(item) diff --git a/resources/lib/library_sync/process_metadata.py b/resources/lib/library_sync/process_metadata.py index 1d8fb021..5e3c49c3 100644 --- a/resources/lib/library_sync/process_metadata.py +++ b/resources/lib/library_sync/process_metadata.py @@ -106,4 +106,8 @@ class ProcessMetadata(backgroundthread.KillableThread, common.libsync_mixin): finally: if self.dialog: self.dialog.close() + while not self.queue.empty(): + # We need to empty the queue to let full_sync finish join() + self.queue.get() + self.queue.task_done() LOG.debug('Processing thread terminated')