Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Catching error to avoid disrupting cron
Browse files Browse the repository at this point in the history
  • Loading branch information
pdonorio committed Sep 25, 2017
1 parent 5b2fe7f commit d5d85fd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion utilities/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@ def list(self):
return self._cron.jobs

def run(self):

import time

while True:
self._cron.run_pending()

# FIXME: this is a draft catching exceptions,
# to be further tested and improved
try:
self._cron.run_pending()
except BaseException as e:
etype = e.__class__.__name__
if etype == 'KeyboardInterrupt':
log.exit("Killed by user")
log.warning(
"Failed to execute cron job\n%s(%s)", etype, e)

time.sleep(1)

0 comments on commit d5d85fd

Please sign in to comment.