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
19 changes: 19 additions & 0 deletions src/aws_durable_execution_sdk_python_testing/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(
self._completion_events: dict[str, Event] = {}
self._callback_timeouts: dict[str, Future] = {}
self._callback_heartbeats: dict[str, Future] = {}
self._execution_timeout: Future | None = None

def start_execution(
self,
Expand Down Expand Up @@ -118,6 +119,21 @@ def start_execution(
completion_event = self._scheduler.create_event()
self._completion_events[execution.durable_execution_arn] = completion_event

# Schedule execution timeout
if input.execution_timeout_seconds > 0:

def timeout_handler():
error = ErrorObject.from_message(
f"Execution timed out after {input.execution_timeout_seconds} seconds."
)
self.on_timed_out(execution.durable_execution_arn, error)

self._execution_timeout = self._scheduler.call_later(
timeout_handler,
delay=input.execution_timeout_seconds,
completion_event=completion_event,
)

# Schedule initial invocation to run immediately
self._invoke_execution(execution.durable_execution_arn)

Expand Down Expand Up @@ -897,6 +913,9 @@ def _complete_events(self, execution_arn: str):
# complete doesn't actually checkpoint explicitly
if event := self._completion_events.get(execution_arn):
event.set()
if self._execution_timeout:
self._execution_timeout.cancel()
self._execution_timeout = None

def wait_until_complete(
self, execution_arn: str, timeout: float | None = None
Expand Down
Loading
Loading