You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Docs: Correction of code sample using idempotent_function in combination with Batch utility #1745
The code sample using batch_processor decorator has the following calling order, where save_inprogress is called before register_lambda_context is called.
Shouldn't we change to using context manager instead of decorator?
Also, shouldn't the dummy call be after register_lambda_context?
defhandler(event, context):
config.register_lambda_context(context) # see Lambda timeouts section# `data` parameter must be called as a keyword argument to workdummy("hello", "universe", data="test")
batch=event["Records"]
withprocessor(records=batch, handler=record_handler):
processor.process()
returnprocessor.response()
Acknowledgment
I understand the final update might be different from my proposed suggestion, or refused.
hey @kt-hr great catch on register_lambda_context order - fixing that now.
As to your question on context manager, there is no need here unless you want to inspect the response or handle when the entire batch fails differently - see here.
I understood the difference between context manager and decorator in the batch utility. However, @idempotent_function is processed before register_lambda_context in decorator, which conflicts with the following sentence in the documentation.
Activity
heitorlessa commentedon Nov 24, 2022
hey @kt-hr great catch on
register_lambda_contextorder - fixing that now.As to your question on context manager, there is no need here unless you want to inspect the response or handle when the entire batch fails differently - see here.
github-actions commentedon Nov 24, 2022
This is now released under 2.4.0 version!
kmkhr commentedon Nov 24, 2022
hi @heitorlessa thanks for the quick correction.
I understood the difference between context manager and decorator in the batch utility. However,
@idempotent_functionis processed beforeregister_lambda_contextin decorator, which conflicts with the following sentence in the documentation.Furthermore, when the code sample is run, lambda outputs the following warnings on every cold start.
To suppress this warning, I have purposely described a code sample using context manger.