From d16822e871881d8cdb6c30482a6490fb3246e1cb Mon Sep 17 00:00:00 2001 From: Lindy Lindstrom Date: Wed, 13 Sep 2023 22:40:48 +0000 Subject: [PATCH] isolate exceptions raised in strategy.run() from cadence to cadence --- .../management/commands/runcadencestrategies.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tom_observations/management/commands/runcadencestrategies.py b/tom_observations/management/commands/runcadencestrategies.py index 32e575daa..73adbbec8 100644 --- a/tom_observations/management/commands/runcadencestrategies.py +++ b/tom_observations/management/commands/runcadencestrategies.py @@ -1,4 +1,5 @@ import logging +import traceback from django.core.management.base import BaseCommand @@ -26,7 +27,13 @@ def handle(self, *args, **kwargs): for cg in cadenced_groups: try: strategy = get_cadence_strategy(cg.cadence_strategy)(cg) - new_observations = strategy.run() + try: + new_observations = strategy.run() + except Exception as e: + logger.error((f'Unable to run cadence_group: {cg}; strategy {strategy};' + f' with id {cg.id} due to error: {e}')) + logger.error(f'{traceback.format_exc()}') + continue if not new_observations: logger.log(msg=f'No changes from dynamic cadence {cg}', level=logging.INFO) else: