diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2022-05-06 18:59:51 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2022-05-06 18:59:51 +0200 |
commit | 3b8003c5a58629ca1347577c253edd63273e1f00 (patch) | |
tree | a9bdc42494df61c0c23d5f3d36774b538dcf6a0b | |
parent | 836617b8e15ef5de6b363dcbde6776774827505c (diff) |
fbin-scanner: Add exception handling to poll_loop
-rw-r--r-- | fbin-scanner.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fbin-scanner.py b/fbin-scanner.py index 2653903..3dac420 100644 --- a/fbin-scanner.py +++ b/fbin-scanner.py @@ -135,9 +135,14 @@ def poll_loop(): now = datetime.datetime(1970, 1, 1) next_now = datetime.datetime.utcnow() while True: - process_files([File.scanned == False, File.date >= now]) # noqa: E712 - now = next_now - next_now = datetime.datetime.utcnow() + try: + process_files([File.scanned == False, File.date >= now]) # noqa: E712 + now = next_now + next_now = datetime.datetime.utcnow() + except Exception: + # On errors, log the exception and retry. Don't update 'now' so that we will retry with the same files. + # This tends to happen eg. when we process a file but it's been deleted when we try to update it. + logger.exception('Error while processing files') time.sleep(60) |