Use localize instead of replace when writing tz info #1026
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We recently encountered an issue where the
run_time
for JobRun instances was consistently offset by 7 minutes earlier than the expected time. This was causing scheduled Jobs to execute earlier than intended, leading to incorrect Job executions.This issue looks to related to our use of
run_time.replace(tzinfo=...)
which incorrectly handles timezone writing. This misuse resulted in the run_time being assigned a tzinfo with an unexpected offset, such as<DstTzInfo 'US/Pacific' LMT-1 day, 16:07:00 STD>
, which has an offset of -7 minutes from the expected timezone offset.Note: I do think adding tests would be ideal, but I haven't gotten that far.