Skip to content

Commit a52ab08

Browse files
leandrodamascenayaythomas
authored andcommitted
fix: honor timed_out terminal state
1 parent 637a1a8 commit a52ab08

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/aws_durable_execution_sdk_python/state.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ def track_replay(self, operation_id: str) -> None:
314314
OperationStatus.FAILED,
315315
OperationStatus.CANCELLED,
316316
OperationStatus.STOPPED,
317+
OperationStatus.TIMED_OUT,
317318
}
318319
}
319320
if completed_ops.issubset(self._visited_operations):

tests/state_test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3265,3 +3265,36 @@ def test_state_replay_mode():
32653265
assert execution_state.is_replaying() is True
32663266
execution_state.track_replay(operation_id="op2")
32673267
assert execution_state.is_replaying() is False
3268+
3269+
3270+
def test_state_replay_mode_with_timed_out():
3271+
"""Test that TIMED_OUT operations are treated as terminal states for replay tracking.
3272+
3273+
This test verifies that when an operation has TIMED_OUT status, it is correctly
3274+
recognized as a completed/terminal state, allowing the replay status to transition
3275+
from REPLAY to NEW once all completed operations have been visited.
3276+
3277+
Regression test for: https://github.com/aws/aws-durable-execution-sdk-python/issues/262
3278+
"""
3279+
operation1 = Operation(
3280+
operation_id="op1",
3281+
operation_type=OperationType.STEP,
3282+
status=OperationStatus.TIMED_OUT,
3283+
)
3284+
operation2 = Operation(
3285+
operation_id="op2",
3286+
operation_type=OperationType.STEP,
3287+
status=OperationStatus.SUCCEEDED,
3288+
)
3289+
execution_state = ExecutionState(
3290+
durable_execution_arn="arn:aws:test",
3291+
initial_checkpoint_token="test_token", # noqa: S106
3292+
operations={"op1": operation1, "op2": operation2},
3293+
service_client=Mock(),
3294+
replay_status=ReplayStatus.REPLAY,
3295+
)
3296+
assert execution_state.is_replaying() is True
3297+
execution_state.track_replay(operation_id="op1")
3298+
assert execution_state.is_replaying() is True
3299+
execution_state.track_replay(operation_id="op2")
3300+
assert execution_state.is_replaying() is False

0 commit comments

Comments
 (0)