Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/aws_durable_execution_sdk_python/operation/invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def invoke_handler(
)
return None # type: ignore

if checkpointed_result.is_failed() or checkpointed_result.is_timed_out():
if (
checkpointed_result.is_failed()
or checkpointed_result.is_timed_out()
or checkpointed_result.is_stopped()
):
# Operation failed, throw the exact same error on replay as the checkpointed failure
checkpointed_result.raise_callable_error()

Expand Down
8 changes: 8 additions & 0 deletions src/aws_durable_execution_sdk_python/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def is_failed(self) -> bool:

return op.status is OperationStatus.FAILED

def is_stopped(self) -> bool:
"""Return True if the checkpointed operation is STOPPED"""
op = self.operation
if not op:
return False

return op.status is OperationStatus.STOPPED

def is_started(self) -> bool:
"""Return True if the checkpointed operation is STARTED."""
op = self.operation
Expand Down
7 changes: 5 additions & 2 deletions tests/operation/invoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ def test_invoke_handler_already_succeeded_no_chained_invoke_details():
assert result is None


def test_invoke_handler_already_failed():
@pytest.mark.parametrize(
"kind", [OperationStatus.FAILED, OperationStatus.STOPPED, OperationStatus.TIMED_OUT]
)
def test_invoke_handler_already_terminated(kind: OperationStatus):
"""Test invoke_handler when operation already failed."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
Expand All @@ -118,7 +121,7 @@ def test_invoke_handler_already_failed():
operation = Operation(
operation_id="invoke4",
operation_type=OperationType.CHAINED_INVOKE,
status=OperationStatus.FAILED,
status=kind,
chained_invoke_details=ChainedInvokeDetails(error=error),
)
mock_result = CheckpointedResult.create_from_operation(operation)
Expand Down