2828 ResourceNotFoundException ,
2929)
3030from aws_durable_execution_sdk_python_testing .execution import Execution
31+ from aws_durable_execution_sdk_python_testing .exceptions import IllegalStateException
3132from aws_durable_execution_sdk_python_testing .model import (
3233 CheckpointDurableExecutionResponse ,
3334 CheckpointUpdatedExecutionState ,
@@ -611,8 +612,12 @@ def checkpoint_execution(
611612 new_execution_state = new_execution_state ,
612613 )
613614
615+ # Save execution state after generating new token
616+ new_checkpoint_token = execution .get_new_checkpoint_token ()
617+ self ._store .update (execution )
618+
614619 return CheckpointDurableExecutionResponse (
615- checkpoint_token = execution . get_new_checkpoint_token () ,
620+ checkpoint_token = new_checkpoint_token ,
616621 new_execution_state = None ,
617622 )
618623
@@ -644,6 +649,7 @@ def send_callback_success(
644649 execution .complete_callback_success (callback_id , result )
645650 self ._store .update (execution )
646651 self ._cleanup_callback_timeouts (callback_id )
652+ self ._invoke_execution (callback_token .execution_arn )
647653 logger .info ("Callback success completed for callback_id: %s" , callback_id )
648654 except Exception as e :
649655 msg = f"Failed to process callback success: { e } "
@@ -681,6 +687,7 @@ def send_callback_failure(
681687 execution .complete_callback_failure (callback_id , callback_error )
682688 self ._store .update (execution )
683689 self ._cleanup_callback_timeouts (callback_id )
690+ self ._invoke_execution (callback_token .execution_arn )
684691 logger .info ("Callback failure completed for callback_id: %s" , callback_id )
685692 except Exception as e :
686693 msg = f"Failed to process callback failure: { e } "
@@ -944,7 +951,7 @@ def complete_execution(self, execution_arn: str, result: str | None = None) -> N
944951
945952 def fail_execution (self , execution_arn : str , error : ErrorObject ) -> None :
946953 """Fail execution with error."""
947- logger .exception ("[%s] Completing execution with error. " , execution_arn )
954+ logger .error ("[%s] Completing execution with error: %s " , execution_arn , error )
948955 execution : Execution = self ._store .load (execution_arn = execution_arn )
949956 execution .complete_fail (error = error )
950957 self ._store .update (execution )
@@ -1190,9 +1197,8 @@ def _on_callback_timeout(self, execution_arn: str, callback_id: str) -> None:
11901197 f"Callback timed out: { CallbackTimeoutType .TIMEOUT .value } "
11911198 )
11921199 execution .complete_callback_failure (callback_id , timeout_error )
1200+ execution .complete_fail (timeout_error )
11931201 self ._store .update (execution )
1194- self ._invoke_execution (execution_arn )
1195-
11961202 logger .warning ("[%s] Callback %s timed out" , execution_arn , callback_id )
11971203 except Exception :
11981204 logger .exception (
@@ -1218,9 +1224,8 @@ def _on_callback_heartbeat_timeout(
12181224 f"Callback heartbeat timed out: { CallbackTimeoutType .HEARTBEAT .value } "
12191225 )
12201226 execution .complete_callback_failure (callback_id , heartbeat_error )
1227+ execution .complete_fail (heartbeat_error )
12211228 self ._store .update (execution )
1222- self ._invoke_execution (execution_arn )
1223-
12241229 logger .warning (
12251230 "[%s] Callback %s heartbeat timed out" , execution_arn , callback_id
12261231 )
0 commit comments