Skip to content

Commit

Permalink
Retry get task on communication exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Nov 4, 2024
1 parent 4f481e0 commit 7d96385
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/isar/state_machine/states/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
RobotException,
RobotRetrieveInspectionException,
RobotTaskStatusException,
RobotCommunicationException,
)
from robot_interface.models.inspection.inspection import Inspection
from robot_interface.models.mission.mission import Mission
Expand Down Expand Up @@ -75,8 +76,11 @@ def _run(self) -> None:
time.sleep(self.state_machine.sleep_time)
continue

except RobotCommunicationTimeoutException as e:
task_failed: bool = self._handle_communication_timeout(e)
except (
RobotCommunicationTimeoutException,
RobotCommunicationException,
) as e:
task_failed: bool = self._handle_communication_retry(e)
if task_failed:
status = TaskStatus.Failed
else:
Expand Down Expand Up @@ -210,8 +214,8 @@ def _set_error_message(self, e: RobotException) -> None:
)
self.state_machine.current_task.error_message = error_message

def _handle_communication_timeout(
self, e: RobotCommunicationTimeoutException
def _handle_communication_retry(
self, e: Union[RobotCommunicationTimeoutException, RobotCommunicationException]
) -> bool:
self.state_machine.current_mission.error_message = ErrorMessage(
error_reason=e.error_reason, error_description=e.error_description
Expand Down
2 changes: 1 addition & 1 deletion src/robot_interface/models/exceptions/robot_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, error_reason: ErrorReason, error_description: str):


# An exception which should be thrown by the robot package if it is unable to
# communicate with the robot API.
# communicate with the robot API. ISAR will retry the request.
class RobotCommunicationException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
Expand Down

0 comments on commit 7d96385

Please sign in to comment.