Skip to content

Commit 2e1afd3

Browse files
committed
chore(idempotency): address comments
1 parent 5c09a5a commit 2e1afd3

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

aws_lambda_powertools/utilities/idempotency/persistence/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,14 @@ def save_inprogress(self, data: Dict[str, Any], remaining_time_in_millis: Option
353353
if remaining_time_in_millis:
354354
now = datetime.datetime.now()
355355
period = datetime.timedelta(milliseconds=remaining_time_in_millis)
356+
timestamp = (now + period).timestamp()
356357

357-
data_record.in_progress_expiry_timestamp = int((now + period).timestamp() * 1000)
358+
data_record.in_progress_expiry_timestamp = int(timestamp * 1000)
358359
else:
359-
warnings.warn("Expires in progress is enabled but we couldn't determine the remaining time left")
360+
warnings.warn(
361+
"Couldn't determine the remaining time left. "
362+
"Did you call register_lambda_context on IdempotencyConfig?"
363+
)
360364

361365
logger.debug(f"Saving in progress record for idempotency key: {data_record.idempotency_key}")
362366

tests/functional/idempotency/test_idempotency.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,10 @@ def function(record):
782782
warnings.simplefilter("default")
783783
function(record=mock_event)
784784
assert len(w) == 1
785-
assert str(w[-1].message) == "Expires in progress is enabled but we couldn't determine the remaining time left"
785+
assert (
786+
str(w[-1].message)
787+
== "Couldn't determine the remaining time left. Did you call register_lambda_context on IdempotencyConfig?"
788+
)
786789

787790

788791
def test_data_record_invalid_status_value():

0 commit comments

Comments
 (0)