Revert "Fix Kodi crash by committing to DB frequently"
This reverts commit 535163b675
.
This commit is contained in:
parent
986981527e
commit
4b3f641f25
1 changed files with 6 additions and 14 deletions
|
@ -12,11 +12,6 @@ from . import sync_info
|
||||||
###############################################################################
|
###############################################################################
|
||||||
LOG = getLogger("PLEX." + __name__)
|
LOG = getLogger("PLEX." + __name__)
|
||||||
|
|
||||||
# Commit to DB happens only after leaving respective itemtypes context manager
|
|
||||||
# with item_fct() as item_class:
|
|
||||||
# After how many items shall we additionally commit? Otherwise, Kodi
|
|
||||||
# crashes if we sync thousands of items without a single commit.
|
|
||||||
COMMIT_AFTER_N_ITEMS = 1000
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,12 +57,14 @@ class ThreadedProcessMetadata(Thread):
|
||||||
LOG.debug('Processing thread started')
|
LOG.debug('Processing thread started')
|
||||||
# Constructs the method name, e.g. itemtypes.Movies
|
# Constructs the method name, e.g. itemtypes.Movies
|
||||||
item_fct = getattr(itemtypes, self.item_class)
|
item_fct = getattr(itemtypes, self.item_class)
|
||||||
n = 0
|
# cache local variables because it's faster
|
||||||
|
queue = self.queue
|
||||||
|
stopped = self.stopped
|
||||||
with item_fct() as item_class:
|
with item_fct() as item_class:
|
||||||
while self.stopped() is False:
|
while stopped() is False:
|
||||||
# grabs item from queue
|
# grabs item from queue
|
||||||
try:
|
try:
|
||||||
item = self.queue.get(block=False)
|
item = queue.get(block=False)
|
||||||
except Empty:
|
except Empty:
|
||||||
sleep(20)
|
sleep(20)
|
||||||
continue
|
continue
|
||||||
|
@ -86,11 +83,6 @@ class ThreadedProcessMetadata(Thread):
|
||||||
with sync_info.LOCK:
|
with sync_info.LOCK:
|
||||||
sync_info.PROCESS_METADATA_COUNT += 1
|
sync_info.PROCESS_METADATA_COUNT += 1
|
||||||
sync_info.PROCESSING_VIEW_NAME = item['title']
|
sync_info.PROCESSING_VIEW_NAME = item['title']
|
||||||
n += 1
|
queue.task_done()
|
||||||
if n == COMMIT_AFTER_N_ITEMS:
|
|
||||||
n = 0
|
|
||||||
item_class.plexconn.commit()
|
|
||||||
item_class.kodiconn.commit()
|
|
||||||
self.queue.task_done()
|
|
||||||
self.terminate_now()
|
self.terminate_now()
|
||||||
LOG.debug('Processing thread terminated')
|
LOG.debug('Processing thread terminated')
|
||||||
|
|
Loading…
Reference in a new issue