Fix exceptions not being raised during sync
This commit is contained in:
parent
f68b4c8820
commit
3acaad5663
1 changed files with 58 additions and 62 deletions
|
@ -71,13 +71,66 @@ class ProcessMetadata(backgroundthread.KillableThread, common.libsync_mixin):
|
||||||
% (self.current, self.total, self.title))
|
% (self.current, self.total, self.title))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
"""
|
||||||
|
Do the work
|
||||||
|
"""
|
||||||
LOG.debug('Processing thread started')
|
LOG.debug('Processing thread started')
|
||||||
try:
|
try:
|
||||||
self._run()
|
if self.show_dialog:
|
||||||
except:
|
self.dialog = xbmcgui.DialogProgressBG()
|
||||||
utils.ERROR(txt='process_metadata crashed',
|
self.dialog.create(utils.lang(39714))
|
||||||
notify=True,
|
# Init with the very first library section. This will block!
|
||||||
cancel_sync=True)
|
section = self.queue.get()
|
||||||
|
self.queue.task_done()
|
||||||
|
if section is None:
|
||||||
|
return
|
||||||
|
while not self.isCanceled():
|
||||||
|
if section is None:
|
||||||
|
break
|
||||||
|
LOG.debug('Start processing section %s (%ss)',
|
||||||
|
section.name, section.plex_type)
|
||||||
|
self.current = 1
|
||||||
|
self.processed = 0
|
||||||
|
self.total = section.total
|
||||||
|
self.section_name = section.name
|
||||||
|
self.section_type_text = utils.lang(
|
||||||
|
v.TRANSLATION_FROM_PLEXTYPE[section.plex_type])
|
||||||
|
profile = Profile()
|
||||||
|
profile.enable()
|
||||||
|
with section.context(self.last_sync) as context:
|
||||||
|
while not self.isCanceled():
|
||||||
|
# grabs item from queue. This will block!
|
||||||
|
item = self.queue.get()
|
||||||
|
if isinstance(item, InitNewSection) or item is None:
|
||||||
|
section = item
|
||||||
|
self.queue.task_done()
|
||||||
|
break
|
||||||
|
elif isinstance(item, UpdateLastSync):
|
||||||
|
context.plexdb.update_last_sync(item.plex_id,
|
||||||
|
section.plex_type,
|
||||||
|
self.last_sync)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
context.add_update(item['xml'][0],
|
||||||
|
section_name=section.name,
|
||||||
|
section_id=section.id,
|
||||||
|
children=item['children'])
|
||||||
|
except:
|
||||||
|
utils.ERROR()
|
||||||
|
self.title = item['xml'][0].get('title')
|
||||||
|
self.processed += 1
|
||||||
|
self.update_progressbar()
|
||||||
|
self.current += 1
|
||||||
|
if self.processed == 500:
|
||||||
|
self.processed = 0
|
||||||
|
context.commit()
|
||||||
|
self.queue.task_done()
|
||||||
|
profile.disable()
|
||||||
|
string_io = StringIO()
|
||||||
|
stats = Stats(profile, stream=string_io).sort_stats('cumulative')
|
||||||
|
stats.print_stats()
|
||||||
|
LOG.info('cProfile result: ')
|
||||||
|
LOG.info(string_io.getvalue())
|
||||||
finally:
|
finally:
|
||||||
if self.dialog:
|
if self.dialog:
|
||||||
self.dialog.close()
|
self.dialog.close()
|
||||||
|
@ -86,60 +139,3 @@ class ProcessMetadata(backgroundthread.KillableThread, common.libsync_mixin):
|
||||||
self.queue.get()
|
self.queue.get()
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
LOG.debug('Processing thread terminated')
|
LOG.debug('Processing thread terminated')
|
||||||
|
|
||||||
def _run(self):
|
|
||||||
"""
|
|
||||||
Do the work
|
|
||||||
"""
|
|
||||||
if self.show_dialog:
|
|
||||||
self.dialog = xbmcgui.DialogProgressBG()
|
|
||||||
self.dialog.create(utils.lang(39714))
|
|
||||||
# Init with the very first library section. This will block!
|
|
||||||
section = self.queue.get()
|
|
||||||
self.queue.task_done()
|
|
||||||
if section is None:
|
|
||||||
return
|
|
||||||
while not self.isCanceled():
|
|
||||||
if section is None:
|
|
||||||
break
|
|
||||||
LOG.debug('Start processing section %s (%ss)',
|
|
||||||
section.name, section.plex_type)
|
|
||||||
self.current = 1
|
|
||||||
self.processed = 0
|
|
||||||
self.total = section.total
|
|
||||||
self.section_name = section.name
|
|
||||||
self.section_type_text = utils.lang(
|
|
||||||
v.TRANSLATION_FROM_PLEXTYPE[section.plex_type])
|
|
||||||
profile = Profile()
|
|
||||||
profile.enable()
|
|
||||||
with section.context(self.last_sync) as context:
|
|
||||||
while not self.isCanceled():
|
|
||||||
# grabs item from queue. This will block!
|
|
||||||
item = self.queue.get()
|
|
||||||
if isinstance(item, InitNewSection) or item is None:
|
|
||||||
section = item
|
|
||||||
self.queue.task_done()
|
|
||||||
break
|
|
||||||
elif isinstance(item, UpdateLastSync):
|
|
||||||
context.plexdb.update_last_sync(item.plex_id,
|
|
||||||
section.plex_type,
|
|
||||||
self.last_sync)
|
|
||||||
else:
|
|
||||||
context.add_update(item['xml'][0],
|
|
||||||
section_name=section.name,
|
|
||||||
section_id=section.id,
|
|
||||||
children=item['children'])
|
|
||||||
self.title = item['xml'][0].get('title')
|
|
||||||
self.processed += 1
|
|
||||||
self.update_progressbar()
|
|
||||||
self.current += 1
|
|
||||||
if self.processed == 500:
|
|
||||||
self.processed = 0
|
|
||||||
context.commit()
|
|
||||||
self.queue.task_done()
|
|
||||||
profile.disable()
|
|
||||||
string_io = StringIO()
|
|
||||||
stats = Stats(profile, stream=string_io).sort_stats('cumulative')
|
|
||||||
stats.print_stats()
|
|
||||||
LOG.info('cProfile result: ')
|
|
||||||
LOG.info(string_io.getvalue())
|
|
||||||
|
|
Loading…
Reference in a new issue