From aca9b566d2904ca8fe2f0d9af53990a5b185dbc0 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Mon, 16 Oct 2023 12:39:35 +0200 Subject: [PATCH] bug fix for SchedulerInterruptedException, and logging --- SAS/TMSS/backend/services/scheduling/lib/constraints.py | 5 +++-- .../backend/services/scheduling/lib/dynamic_scheduling.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/SAS/TMSS/backend/services/scheduling/lib/constraints.py b/SAS/TMSS/backend/services/scheduling/lib/constraints.py index e206062c66a..51556b93af2 100644 --- a/SAS/TMSS/backend/services/scheduling/lib/constraints.py +++ b/SAS/TMSS/backend/services/scheduling/lib/constraints.py @@ -2302,8 +2302,9 @@ def determine_unschedulable_reason_and_mark_unschedulable_if_needed(scheduling_u if not can_run_without_used_stations(scheduling_unit, lower_bound=scheduling_unit.scheduled_observation_start_time, upper_bound=scheduling_unit.scheduled_observation_stop_time): missing_stations = get_missing_stations_for_scheduling_unit(scheduling_unit) - msg = "Stations %s are already used" % (','.join([str(s) for s in missing_stations]), ) - return mark_independent_subtasks_in_scheduling_unit_blueprint_as_unschedulable(scheduling_unit, msg) + if missing_stations: + msg = "Stations %s are already used" % (','.join([str(s) for s in missing_stations]), ) + return mark_independent_subtasks_in_scheduling_unit_blueprint_as_unschedulable(scheduling_unit, msg) if scheduling_unit.earliest_possible_cycle_start_time is None or scheduling_unit.latest_possible_cycle_stop_time is None: return mark_independent_subtasks_in_scheduling_unit_blueprint_as_unschedulable(scheduling_unit, "unknown cycle bounds") diff --git a/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py b/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py index de506eef3c3..6a71178d3e0 100644 --- a/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py +++ b/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py @@ -258,7 +258,10 @@ class Scheduler: self.log_schedule(log_level=logging.DEBUG) except Exception as e: - if isinstance(e, SubtaskSchedulingException): + if isinstance(e, SchedulerInterruptedException): + # Scheduler was interrupted, re-raise and let the scheduling loop handle it + raise + elif isinstance(e, SubtaskSchedulingException): logger.warning("Could not schedule fixed_time-scheduled scheduling unit id=%d: %s", schedulable_unit.id, e) else: logger.exception("Could not schedule fixed_time-scheduled scheduling unit id=%d: %s", schedulable_unit.id, e) @@ -940,6 +943,7 @@ class TMSSDynamicSchedulingMessageHandler(TMSSEventMessageHandler): def onSchedulingUnitBlueprintCreated(self, id: int): '''prepare the new scheduling_unit for scheduling. Set unschedulable if project not active.''' + logger.info("onSchedulingUnitBlueprintCreated(id=%s)",id) scheduling_unit = models.SchedulingUnitBlueprint.objects.get(id=id) # mark unschedulable if project not active -- GitLab