diff --git a/SAS/TMSS/backend/services/scheduling/lib/constraints.py b/SAS/TMSS/backend/services/scheduling/lib/constraints.py index 718c009921e32c36c12afa4f680f7cce98b2ff40..4f6024756f05d940856be80fea4ace3f1d47e916 100644 --- a/SAS/TMSS/backend/services/scheduling/lib/constraints.py +++ b/SAS/TMSS/backend/services/scheduling/lib/constraints.py @@ -483,22 +483,26 @@ def can_run_at(scheduling_unit: models.SchedulingUnitBlueprint, proposed_start_t '''determine if the given scheduling_unit can run withing the given timewindow evaluating all constraints from the "constraints" version 1 template :param raise_if_interruped: a callable function which raises under an externally set condition (an 'interrupt' flag was set). This function is/can_be used to interrupt a long-running scheduling call to do an early exit and start a new scheduling call. Default used function is noop (no-operation), thus no interruptable behaviour. ''' - if gridder is None: - gridder = Gridder() + try: + if gridder is None: + gridder = Gridder() - if not can_run_at_within_cycles_bounds(scheduling_unit, proposed_start_time): - return False + if not can_run_at_within_cycles_bounds(scheduling_unit, proposed_start_time): + return False - if not can_run_at_with_time_constraints(scheduling_unit, proposed_start_time): - return False + if not can_run_at_with_time_constraints(scheduling_unit, proposed_start_time): + return False - if not can_run_at_with_daily_constraints(scheduling_unit, proposed_start_time, gridder=gridder): - return False + if not can_run_at_with_daily_constraints(scheduling_unit, proposed_start_time, gridder=gridder): + return False - if not can_run_at_with_sky_constraints(scheduling_unit, proposed_start_time, gridder=gridder): - return False + if not can_run_at_with_sky_constraints(scheduling_unit, proposed_start_time, gridder=gridder): + return False - return True + return True + except Exception as e: + logger.error("can_run_at: unit id=%s proposed_start_time='%s' %s", scheduling_unit.id, proposed_start_time, e) + return False def can_run_before(scheduling_unit: models.SchedulingUnitBlueprint, proposed_start_time: datetime, gridder: Gridder) -> bool: