@@ -95,8 +95,8 @@ def run_worker(
9595 connects to the Temporal server, starts a worker with Lambda-tuned defaults, polls for
9696 tasks until the invocation deadline approaches, and then gracefully shuts down.
9797
98- The *configure* callback is invoked **once per invocation**, inside that invocation's
99- event loop, before the client connects. It may be synchronous or asynchronous:
98+ The *configure* callback is invoked **once per invocation** and may be synchronous or
99+ asynchronous:
100100
101101 * **Synchronous** ``def configure(config) -> None`` — runs per invocation. Use for
102102 static worker definition (task queue, registrations, option tuning) and resources
@@ -108,7 +108,10 @@ def run_worker(
108108 equivalent ``@contextlib.asynccontextmanager``-decorated function) — entered per
109109 invocation. Statements before the single ``yield`` run before the client connects;
110110 the worker runs while the generator is suspended at the ``yield``; statements after
111- the ``yield`` run as teardown once the worker has stopped. This is the recommended
111+ the ``yield`` run as teardown once the worker has stopped. Any ``shutdown_hooks``
112+ registered before the ``yield`` run after the worker stops but *before* the
113+ post-``yield`` teardown, so this resource outlives the hooks (e.g. a telemetry
114+ flush hook can still emit before the resource is closed). This is the recommended
112115 shape for event-loop-bound resources that must live for the duration of the
113116 invocation, such as an ``aioboto3`` S3 client backing the external-storage data
114117 converter (see the async example below).
0 commit comments