diff --git a/robot_framework/config.py b/robot_framework/config.py index d03e67a..a762536 100644 --- a/robot_framework/config.py +++ b/robot_framework/config.py @@ -3,13 +3,16 @@ # The number of times the robot retries on an error before terminating. MAX_RETRY_COUNT = 3 +# Number of attempts per queue_element (1 is no retry, 2 is 2 total attempts and so on) +QUEUE_ATTEMPTS = 1 + # Whether the robot should be marked as failed if MAX_RETRY_COUNT is reached. FAIL_ROBOT_ON_TOO_MANY_ERRORS = True # Error screenshot config SMTP_SERVER = "smtp.adm.aarhuskommune.dk" SMTP_PORT = 25 -SCREENSHOT_SENDER = "robot@friend.dk" +SCREENSHOT_SENDER = "robot@aarhus.dk" # Constant/Credential names ERROR_EMAIL = "Error Email" diff --git a/robot_framework/queue_framework.py b/robot_framework/queue_framework.py index 57e3850..dc6c884 100644 --- a/robot_framework/queue_framework.py +++ b/robot_framework/queue_framework.py @@ -41,7 +41,17 @@ def main(): break # Break queue loop try: - process.process(orchestrator_connection, queue_element) + for attempt in range(1, config.QUEUE_ATTEMPTS + 1): + try: + process.process(orchestrator_connection, queue_element) + break + except Exception as e: + orchestrator_connection.log_trace(f"Attempt {attempt} failed for current queue element: {e}") + if attempt < config.QUEUE_ATTEMPTS: + orchestrator_connection.log_trace("Retrying queue element.") + else: + orchestrator_connection.log_trace(f"Queue element failed after {attempt} attempts.") + raise orchestrator_connection.set_queue_element_status(queue_element.id, QueueStatus.DONE) except BusinessError as error: