22
33from __future__ import annotations
44
5- import json
65import logging
76import time
87from typing import TYPE_CHECKING , TypeVar
1312)
1413from aws_durable_functions_sdk_python .lambda_service import ErrorObject , OperationUpdate
1514from aws_durable_functions_sdk_python .logger import LogInfo
15+ from aws_durable_functions_sdk_python .serdes import deserialize , serialize
1616from aws_durable_functions_sdk_python .types import WaitForConditionCheckContext
1717
1818if TYPE_CHECKING :
2626 from aws_durable_functions_sdk_python .logger import Logger
2727 from aws_durable_functions_sdk_python .state import ExecutionState
2828
29+
2930T = TypeVar ("T" )
3031
3132logger = logging .getLogger (__name__ )
@@ -57,10 +58,14 @@ def wait_for_condition_handler(
5758 operation_identifier .operation_id ,
5859 operation_identifier .name ,
5960 )
60- # TODO: use serdes from config
6161 if checkpointed_result .result is None :
6262 return None # type: ignore
63- return json .loads (checkpointed_result .result )
63+ return deserialize (
64+ serdes = config .serdes ,
65+ data = checkpointed_result .result ,
66+ operation_id = operation_identifier .operation_id ,
67+ durable_execution_arn = state .durable_execution_arn ,
68+ )
6469
6570 if checkpointed_result .is_failed ():
6671 checkpointed_result .raise_callable_error ()
@@ -69,9 +74,13 @@ def wait_for_condition_handler(
6974 if checkpointed_result .is_started_or_ready ():
7075 # This is a retry - get state from previous checkpoint
7176 if checkpointed_result .result :
72- # TODO: serdes here
7377 try :
74- current_state = json .loads (checkpointed_result .result )
78+ current_state = deserialize (
79+ serdes = config .serdes ,
80+ data = checkpointed_result .result ,
81+ operation_id = operation_identifier .operation_id ,
82+ durable_execution_arn = state .durable_execution_arn ,
83+ )
7584 except Exception :
7685 # default to initial state if there's an error getting checkpointed state
7786 logger .exception (
@@ -117,8 +126,12 @@ def wait_for_condition_handler(
117126 # Check if condition is met with the wait strategy
118127 decision : WaitForConditionDecision = config .wait_strategy (new_state , attempt )
119128
120- # TODO: SerDes here
121- serialized_state = json .dumps (new_state )
129+ serialized_state = serialize (
130+ serdes = config .serdes ,
131+ value = new_state ,
132+ operation_id = operation_identifier .operation_id ,
133+ durable_execution_arn = state .durable_execution_arn ,
134+ )
122135
123136 logger .debug (
124137 "wait_for_condition check completed: %s, name: %s, attempt: %s" ,
0 commit comments