trackdb: Retry saving if something goes wrong

Occasionally we have a problem with tags changing during pickling. If
this happens, reschedule the save for later and hope it doesn't happen
again

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-07-01 10:14:20 -04:00
parent d1456b14bd
commit 11c9f0b267
1 changed files with 5 additions and 2 deletions

View File

@ -63,8 +63,11 @@ Library = LibraryStore()
def _do_save():
with lib.data.DataFile(File, lib.data.WRITE) as f:
f.pickle([ tags.get_state(), Tracks, Library ])
try:
with lib.data.DataFile(File, lib.data.WRITE) as f:
f.pickle([ tags.get_state(), Tracks, Library ])
except Exception as e:
return lib.bus.RETRY
def save(*args):
Bus.board(_do_save)