From 76c5a25fa580319923d7b45eee9bf0b49e3864b8 Mon Sep 17 00:00:00 2001
From: Mario Raciti <mario.raciti@inaf.it>
Date: Mon, 5 Jul 2021 17:32:27 +0200
Subject: [PATCH] TMSS-655: Code cleanup

---
 SAS/TMSS/backend/src/tmss/tmssapp/subtasks.py | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/subtasks.py b/SAS/TMSS/backend/src/tmss/tmssapp/subtasks.py
index 3c2973d3c34..5d9a4610222 100644
--- a/SAS/TMSS/backend/src/tmss/tmssapp/subtasks.py
+++ b/SAS/TMSS/backend/src/tmss/tmssapp/subtasks.py
@@ -1032,28 +1032,19 @@ def _check_stations_for_observations(subtask: Subtask, ra_spec):
     :param subtask:
     :param ra_spec:
     """
-
-    MAX_NBR_ASSIGNMENTS = 10
-
-    i = assigned = 0
+    assigned = False
     with RARPC.create() as rarpc:
-        while not assigned and i < MAX_NBR_ASSIGNMENTS:
+        while not assigned:
             try:
                 assigned = rarpc.do_assignment(ra_spec)
-                i += 0
             except ScheduleException as e:
-                logger.error(e)
+                logger.exception(e)
             if not assigned:
                 logger.info("Conflicts in assignment detected, checking stations in conflict and re-assign if possible")
                 lst_stations_in_conflict = get_stations_in_conflict(subtask.id)
                 lst_stations = determine_stations_which_can_be_assigned(subtask, lst_stations_in_conflict)
                 ra_spec = update_specification(ra_spec, lst_stations)
 
-    # At the end still not possible to assign, give Exception.
-    if not assigned:
-        raise SubtaskSchedulingException("Cannot schedule/unschedule subtask id=%d within %d number of attempts. "
-                                         "The required resources are not (fully) available." % (subtask.pk, i))
-
 
 def get_stations_in_conflict(subtask_id):
     """
-- 
GitLab