Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38620e3

Browse files
committed
Use same util function to get current time
datetime.utcnow() is deprecated and was giving a 2-hour difference result than get_current_time() for a computer running in CEST timezone. This led to valid records being expired in bisect_events_by_record_age in stream poller. Same function needs to be used across the code, especially when a comparison is made within same logic.
1 parent 9769022 commit 38620e3

File tree

1 file changed

+2
-1
lines changed
  • localstack-core/localstack/services/lambda_/event_source_mapping/pollers

1 file changed

+2
-1
lines changed

‎localstack-core/localstack/services/lambda_/event_source_mapping/pollers/dynamodb_poller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from localstack.services.lambda_.event_source_mapping.event_processor import (
88
EventProcessor,
99
)
10+
from localstack.services.lambda_.event_source_mapping.pipe_utils import get_current_time
1011
from localstack.services.lambda_.event_source_mapping.pollers.stream_poller import StreamPoller
1112

1213
LOG = logging.getLogger(__name__)
@@ -109,7 +110,7 @@ def get_approximate_arrival_time(self, record: dict) -> float:
109110
# Optional according to AWS docs:
110111
# https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_StreamRecord.html
111112
# TODO: parse float properly if present from ApproximateCreationDateTime -> now works, compare via debug!
112-
return record["dynamodb"].get("todo", datetime.utcnow().timestamp())
113+
return record["dynamodb"].get("todo", get_current_time().timestamp())
113114

114115
def format_datetime(self, time: datetime) -> str:
115116
return f"{time.isoformat(timespec='seconds')}Z"

0 commit comments

Comments
 (0)