Skip to content

Commit dd90766

Browse files
committed
docs(idempotency): cleanup timeout section
Signed-off-by: heitorlessa <[email protected]>
1 parent 108f456 commit dd90766

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

docs/utilities/idempotency.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -319,35 +319,23 @@ You can change this expiration window with the **`expires_after_seconds`** param
319319

320320
### Lambda timeouts
321321

322-
???+ note
323-
This is automatically done when you decorate your Lambda handler with [@idempotent decorator](#idempotent-decorator).
324-
325-
To prevent against extended failed retries when a [Lambda function times out](https://aws.amazon.com/premiumsupport/knowledge-center/lambda-verify-invocation-timeouts/){target="_blank"},
326-
Powertools for AWS Lambda (Python) calculates and includes the remaining invocation available time as part of the idempotency record.
322+
By default, we protect against [concurrent executions](#handling-concurrent-executions-with-the-same-payload) with the same payload using a locking mechanism. However, if your Lambda function times out before completing the first invocation it will only accept the same request when the [idempotency record expire](#expiring-idempotency-records).
327323

328324
To prevent extended failures, use **`register_lambda_context`** function from your idempotency config to calculate and include the remaining invocation time in your idempotency record.
329325

330-
```python title="working_with_lambda_timeout.py" hl_lines="14 23"
331-
--8<-- "examples/idempotency/src/working_with_lambda_timeout.py"
332-
```
326+
=== "Registering the Lambda context"
327+
328+
> This is unnecessary for [`@idempotent` decorator](#idempotent-decorator), as it captures the Lambda context from your handler function.
329+
330+
```python title="working_with_lambda_timeout.py" hl_lines="11 20"
331+
--8<-- "examples/idempotency/src/working_with_lambda_timeout.py"
332+
```
333333

334334
???+ example "Mechanics"
335335
If a second invocation happens **after** this timestamp, and the record is marked as `INPROGRESS`, we will run the invocation again as if it was in the `EXPIRED` state.
336336

337337
This means that if an invocation expired during execution, it will be quickly executed again on the next retry.
338338

339-
???+ important
340-
If you are only using the [@idempotent_function decorator](#idempotent_function-decorator) to guard isolated parts of your code,
341-
you must use `register_lambda_context` available in the [idempotency config object](#customizing-the-default-behavior) to benefit from this protection.
342-
343-
Here is an example on how you register the Lambda context in your handler:
344-
345-
=== "Registering the Lambda context"
346-
347-
```python hl_lines="11 20"
348-
--8<-- "examples/idempotency/src/working_with_lambda_timeout.py"
349-
```
350-
351339
### Handling exceptions
352340

353341
There are two failure modes that can cause new invocations to execute your code again despite having the same payload:

0 commit comments

Comments
 (0)