From f4bbe6afb88215a94641ee7cb6efcda4fb8b3f3d Mon Sep 17 00:00:00 2001 From: Dhruv Garg Date: Wed, 4 Dec 2024 12:29:50 -0500 Subject: [PATCH] [simulator] check task state before invoking unschedule on it --- simulator.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/simulator.py b/simulator.py index 6f3bf572..e55f1665 100644 --- a/simulator.py +++ b/simulator.py @@ -1445,17 +1445,22 @@ def subtree_tasks_to_unschedule(task): self._logger.warning(msg) # Unschedule the task - unschedule_task.unschedule(event.time) - self._csv_logger.debug( - f"{event.time.time},TASK_UNSCHEDULED,{unschedule_task.name},{unschedule_task.timestamp}," - f"{unschedule_task.id},{unschedule_task.task_graph}" - ) - - self._logger.info( - "[%s] Finished unscheduling of task %s.", - event.time.time, - unschedule_task, - ) + if unschedule_task.state == TaskState.SCHEDULED: + unschedule_task.unschedule(event.time) + self._csv_logger.debug( + f"{event.time.time},TASK_UNSCHEDULED,{unschedule_task.name},{unschedule_task.timestamp}," + f"{unschedule_task.id},{unschedule_task.task_graph}" + ) + msg = ( + f"[{event.time.time}] Finished unscheduling of task {unschedule_task}." + ) + self._logger.info(msg) + else: + msg = ( + f"[{event.time.time}] Task {unschedule_task} was not in SCHEDULED state and was in " + f"{unschedule_task.state} state. Skip unscheduling." + ) + self._logger.info(msg) if not task.is_ready_to_run(task_graph): if task.state == TaskState.CANCELLED or task_graph.is_cancelled():