Skip to content

Commit

Permalink
Log exceptions in cron jobs. (#4571)
Browse files Browse the repository at this point in the history
It was noticed in #4568 that exceptions in cron jobs aren't logged. This
is very important.
  • Loading branch information
jonathanmetzman authored Jan 2, 2025
1 parent cbba25e commit 103ab02
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/python/bot/startup/run_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ def main():

task_module_name = f'clusterfuzz._internal.cron.{task}'
with monitor.wrap_with_monitoring(), ndb_init.context():
task_module = importlib.import_module(task_module_name)
return 0 if task_module.main() else 1
try:
task_module = importlib.import_module(task_module_name)
return 0 if task_module.main() else 1
except Exception as e:
logs.error(f'Unhandled exception in cron: {e}')
return 1


if __name__ == '__main__':
Expand Down

0 comments on commit 103ab02

Please sign in to comment.