Skip to content

Docs: Correction of code sample using idempotent_function in combination with Batch utility #1745

Closed
@kmkhr

Description

@kmkhr

What were you searching in the docs?

I was looking into ways to combine Idempotency utility and Batch utility.

Is this related to an existing documentation section?

https://awslabs.github.io/aws-lambda-powertools-python/2.3.1/utilities/idempotency/#idempotent_function-decorator

How can we improve?

The code sample using batch_processor decorator has the following calling order, where save_inprogress is called before register_lambda_context is called.

batch_processor -> idempotent_function -> save_inprogress -> record_handler -> idempotent_function -> save_inprogress -> dummy -> register_lambda_context

Got a suggestion in mind?

Shouldn't we change to using context manager instead of decorator?
Also, shouldn't the dummy call be after register_lambda_context?

def handler(event, context):
    config.register_lambda_context(context) # see Lambda timeouts section
    # `data` parameter must be called as a keyword argument to work
    dummy("hello", "universe", data="test")
    batch = event["Records"]
    with processor(records=batch, handler=record_handler):
        processor.process()
    return processor.response()

Acknowledgment

  • I understand the final update might be different from my proposed suggestion, or refused.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions