Skip to content

Commit 26df51e

Browse files
authored
💥 Enable lambda worker async configure callback (#1604)
* 💥 enable lambda worker async configure * example adjustment * comment updates * update changelog
1 parent 5067ce5 commit 26df51e

4 files changed

Lines changed: 413 additions & 128 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ to docs, or any other relevant information.
1919

2020
## [Unreleased]
2121

22+
### Changed
23+
24+
- AWS Lambda worker `configure` parameter supports sync, async, and async
25+
generator style functions. This callback is invoked on the asyncio event
26+
loop.
27+
28+
### Breaking Changes
29+
30+
- AWS Lambda worker `configure` parameter has been changed to be invoked
31+
per-invocation of the worker instead of only at startup. It is advised that
32+
any shared, heavy-weight operations are performed outside of the callback
33+
before `run_worker` is invoked.
34+
2235
## [1.29.0] - 2026-06-17
2336

2437
### Added

‎temporalio/contrib/aws/lambda_worker/README.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ pre-populated with Lambda-appropriate defaults. Override any field directly in
4848
the callback. The `task_queue` key in `worker_config` is pre-populated from the
4949
`TEMPORAL_TASK_QUEUE` environment variable if set.
5050

51+
### Sync, async, and async-generator configure
52+
53+
The configure callback runs **once per invocation, inside that invocation's
54+
event loop**, before the client connects. It may be:
55+
56+
- a plain function `def configure(config) -> None`;
57+
- an `async def configure(config) -> None` coroutine — awaited for setup (pair
58+
with `shutdown_hooks` for teardown);
59+
- an `async def configure(config): ...; yield; ...` async generator — statements
60+
before the single `yield` run before the client connects, the worker runs
61+
while the generator is suspended at the `yield`, and statements after the
62+
`yield` run as teardown once the worker has stopped.
63+
64+
The callback runs per invocation (rather than once at process start) because
65+
event-loop-bound resources cannot be created before an event loop exists and
66+
cannot be shared across invocations — each invocation runs under a fresh
67+
`asyncio.run` loop.
68+
5169
## Lambda-tuned worker defaults
5270

5371
The package applies conservative concurrency limits suited to Lambda's resource

0 commit comments

Comments
 (0)