-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathotel_4_terminal_failure.py
More file actions
42 lines (35 loc) · 1.2 KB
/
Copy pathotel_4_terminal_failure.py
File metadata and controls
42 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# SPDX-FileCopyrightText: 2026-present Amazon.com, Inc. or its affiliates.
#
# SPDX-License-Identifier: Apache-2.0
"""Terminal execution failure scenario for OTel requirement otel-invocation-4."""
from __future__ import annotations
from typing import Any
from aws_durable_execution_sdk_python import (
DurableContext,
StepContext,
durable_execution,
durable_step,
)
from aws_durable_execution_sdk_python.config import StepConfig
from aws_durable_execution_sdk_python.retries import (
RetryStrategyConfig,
create_retry_strategy,
)
from common import otel_plugin_factory, require_scenario
@durable_step
def fail_terminally(_step_context: StepContext) -> None:
raise RuntimeError("Intentional terminal failure")
@durable_execution(plugins=[otel_plugin_factory()])
def handler(event: dict[str, Any], context: DurableContext) -> None:
require_scenario(event, "terminal-failure")
retry_strategy = create_retry_strategy(
RetryStrategyConfig(
max_attempts=1,
retryable_error_types=[RuntimeError],
)
)
context.step(
fail_terminally(),
name="otel-terminal-failure",
config=StepConfig(retry_strategy=retry_strategy),
)