Skip to content

Commit d5853f9

Browse files
willmizziyaythomas
authored andcommitted
fix: extend Lambda read_timeout, disable retries
- Introduce a shared Lambda client config with a 960s read_timeout and retries disabled - Route all Lambda client construction through a single helper
1 parent 1cd7468 commit d5853f9

4 files changed

Lines changed: 36 additions & 12 deletions

File tree

src/aws_durable_execution_sdk_python_testing/invoker.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from uuid import uuid4
88

99
import boto3 # type: ignore
10+
from botocore.config import Config # type: ignore
11+
1012
from aws_durable_execution_sdk_python.execution import (
1113
DurableExecutionInvocationInput,
1214
DurableExecutionInvocationInputWithClient,
@@ -29,6 +31,26 @@
2931
from aws_durable_execution_sdk_python_testing.execution import Execution
3032

3133

34+
# Max Lambda function timeout is 15 minutes (900s); we give headroom for
35+
# network round-trip and RIE startup.
36+
_LAMBDA_READ_TIMEOUT_SECONDS = 960
37+
_LAMBDA_CLIENT_CONFIG = Config(
38+
read_timeout=_LAMBDA_READ_TIMEOUT_SECONDS,
39+
retries={"max_attempts": 0},
40+
)
41+
42+
43+
def create_lambda_client(endpoint_url: str | None, region_name: str) -> Any:
44+
"""Create a boto3 Lambda client configured for durable function invocations."""
45+
46+
return boto3.client(
47+
"lambda",
48+
endpoint_url=endpoint_url,
49+
region_name=region_name,
50+
config=_LAMBDA_CLIENT_CONFIG,
51+
)
52+
53+
3254
@dataclass(frozen=True)
3355
class InvokeResponse:
3456
"""Response from invoking a durable function."""
@@ -136,9 +158,7 @@ def __init__(self, lambda_client: Any) -> None:
136158
@staticmethod
137159
def create(endpoint_url: str, region_name: str) -> LambdaInvoker:
138160
"""Create with the boto lambda client."""
139-
invoker = LambdaInvoker(
140-
boto3.client("lambda", endpoint_url=endpoint_url, region_name=region_name)
141-
)
161+
invoker = LambdaInvoker(create_lambda_client(endpoint_url, region_name))
142162
invoker._current_endpoint = endpoint_url
143163
invoker._endpoint_clients[endpoint_url] = invoker.lambda_client
144164
return invoker
@@ -148,8 +168,8 @@ def update_endpoint(self, endpoint_url: str, region_name: str) -> None:
148168
# Cache client by endpoint to reuse across executions
149169
with self._lock:
150170
if endpoint_url not in self._endpoint_clients:
151-
self._endpoint_clients[endpoint_url] = boto3.client(
152-
"lambda", endpoint_url=endpoint_url, region_name=region_name
171+
self._endpoint_clients[endpoint_url] = create_lambda_client(
172+
endpoint_url, region_name
153173
)
154174
self.lambda_client = self._endpoint_clients[endpoint_url]
155175
self._current_endpoint = endpoint_url
@@ -164,10 +184,8 @@ def _get_client_for_execution(
164184
# Use provided endpoint or fall back to cached endpoint for this execution
165185
if lambda_endpoint:
166186
if lambda_endpoint not in self._endpoint_clients:
167-
self._endpoint_clients[lambda_endpoint] = boto3.client(
168-
"lambda",
169-
endpoint_url=lambda_endpoint,
170-
region_name=region_name or "us-east-1",
187+
self._endpoint_clients[lambda_endpoint] = create_lambda_client(
188+
lambda_endpoint, region_name or "us-east-1"
171189
)
172190
return self._endpoint_clients[lambda_endpoint]
173191

src/aws_durable_execution_sdk_python_testing/runner.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from aws_durable_execution_sdk_python_testing.invoker import (
4747
InProcessInvoker,
4848
LambdaInvoker,
49+
create_lambda_client,
4950
)
5051
from aws_durable_execution_sdk_python_testing.model import (
5152
GetDurableExecutionHistoryResponse,
@@ -858,9 +859,7 @@ def _create_boto3_client(self) -> Any:
858859
Exception: If client creation fails - exceptions propagate naturally
859860
for CLI to handle as general Exception
860861
"""
861-
# Create client with Lambda endpoint configuration
862-
return boto3.client(
863-
"lambda",
862+
return create_lambda_client(
864863
endpoint_url=self._config.lambda_endpoint,
865864
region_name=self._config.local_runner_region,
866865
)

tests/invoker_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from aws_durable_execution_sdk_python_testing.invoker import (
2626
InProcessInvoker,
2727
LambdaInvoker,
28+
_LAMBDA_CLIENT_CONFIG,
29+
create_lambda_client,
2830
create_test_lambda_context,
2931
)
3032
from aws_durable_execution_sdk_python_testing.model import (
@@ -133,6 +135,7 @@ def test_lambda_invoker_create():
133135
"lambda",
134136
endpoint_url="http://localhost:3001",
135137
region_name="us-west-2",
138+
config=_LAMBDA_CLIENT_CONFIG,
136139
)
137140

138141

tests/runner_web_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from aws_durable_execution_sdk_python_testing.exceptions import (
1313
DurableFunctionsLocalRunnerError,
1414
)
15+
from aws_durable_execution_sdk_python_testing.invoker import _LAMBDA_CLIENT_CONFIG
1516
from aws_durable_execution_sdk_python_testing.runner import (
1617
WebRunner,
1718
WebRunnerConfig,
@@ -420,6 +421,7 @@ def test_should_handle_boto3_client_creation_with_custom_config():
420421
"lambda",
421422
endpoint_url="http://custom-endpoint:8080",
422423
region_name="eu-west-1",
424+
config=_LAMBDA_CLIENT_CONFIG,
423425
)
424426

425427
# Verify public behavior works
@@ -445,6 +447,7 @@ def test_should_handle_boto3_client_creation_with_defaults():
445447
"lambda",
446448
endpoint_url="http://127.0.0.1:3001", # Default lambda_endpoint value
447449
region_name="us-west-2", # Default value
450+
config=_LAMBDA_CLIENT_CONFIG,
448451
)
449452

450453
# Verify public behavior works
@@ -768,6 +771,7 @@ def test_should_pass_correct_boto3_client_to_lambda_invoker():
768771
"lambda",
769772
endpoint_url="http://test-endpoint:7777",
770773
region_name="ap-southeast-2",
774+
config=_LAMBDA_CLIENT_CONFIG,
771775
)
772776

773777
# Verify LambdaInvoker was created with the client

0 commit comments

Comments
 (0)