From 48810a227fb66bc187bbdce68594d2c4ee8a3f48 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 2 Jun 2018 17:26:36 +0200 Subject: [PATCH] Revert "Fix playqueue monitoring locking mechanism" This reverts commit 1e43f1cc77b9198fabe028472c059b0b321d8c9e. - Should fix a racing condition if the playlist is cleared (picked up by both kodimonitor and playqueue monitor) --- resources/lib/playqueue.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/resources/lib/playqueue.py b/resources/lib/playqueue.py index 3bf8a61b..fd188bb3 100644 --- a/resources/lib/playqueue.py +++ b/resources/lib/playqueue.py @@ -226,26 +226,20 @@ class PlayqueueMonitor(Thread): if stopped(): break sleep(1000) - work = [] - # Detect changed playqueues first, do the work afterwards - with LOCK: - for playqueue in PLAYQUEUES: - kodi_pl = js.playlist_get_items(playqueue.playlistid) - if playqueue.old_kodi_pl != kodi_pl: - if playqueue.id is None and (not state.DIRECT_PATHS or - state.CONTEXT_MENU_PLAY): - # Only initialize if directly fired up using direct - # paths. Otherwise let default.py do its magic - LOG.debug('Not yet initiating playback') - elif playqueue.pkc_edit: - playqueue.pkc_edit = False - LOG.debug('PKC edited the playqueue - skipping') - else: - # We do need to update our playqueues - work.append((playqueue, kodi_pl)) - playqueue.old_kodi_pl = kodi_pl - # Now do the work - LOCK individual playqueue edits - for playqueue, kodi_pl in work: - self._compare_playqueues(playqueue, kodi_pl) + for playqueue in PLAYQUEUES: + kodi_pl = js.playlist_get_items(playqueue.playlistid) + if playqueue.old_kodi_pl != kodi_pl: + if playqueue.id is None and (not state.DIRECT_PATHS or + state.CONTEXT_MENU_PLAY): + # Only initialize if directly fired up using direct + # paths. Otherwise let default.py do its magic + LOG.debug('Not yet initiating playback') + elif playqueue.pkc_edit: + playqueue.pkc_edit = False + LOG.debug('PKC just edited the playqueue - skipping') + else: + # compare old and new playqueue + self._compare_playqueues(playqueue, kodi_pl) + playqueue.old_kodi_pl = list(kodi_pl) sleep(200) LOG.info("----===## PlayqueueMonitor stopped ##===----")