Repository navigation
Fix task ETA issues when timezone is defined in configuration #3867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thedrow
merged 4 commits into
celery:master
from
georgepsarakis:bug/3753_retry_delay_utc_timezone
Mar 2, 2017
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2fa6f91
Fix wrong task ETA when using timezone setting
georgepsarakis 63aa869
Optimization: reduce polling interval in test cases
georgepsarakis 67dad34
Test cases for App.now, App.uses_utc_timezone
georgepsarakis 629799e
Fix PEP8 and pydocstyle issues
georgepsarakis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is wrong. This will not return the current time in
self.timezone. Let's say for example thatself.timezoneis +8 and it is currently12:00 UTC. This method will return12:00 +8, which is the same point in time as04:00 UTC– not12:00 UTC.Note that this current implementation might even return nonsensical times, like
2017-03-25 02:30for a Europe/Berlin timezone – a time that doesn't exist.The correct way to get the current time in a local timezone is
datetime.utcnow().replace(tzinfo=pytz.utc).astimezone(self.timezone). See the same functionality in django and the pytz docs.But you can't just make a function that used to return utc times return times from timezones that observe DST. If the caller code is not aware of that, things might break. Example: You return
2017-03-24 03:30 Europe/Berlin. The caller adds 24h to this and then checks if the time is before04:00. Adding 24h crosses a DST boundary, so the above +24h is actually2017-03-25 04:30. But if you add 24h to a2017-03-24 03:30 Europe/Berlindatetime object, you get2017-03-25 03:30 Europe/Berlin [NON-DST]. You need to calltimezone.normalizeon that to turn that into a sensible datetime object – see the pytz docs.Hope this helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Chronial would you mind sending a pr with your suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Providing a correct implementation using timezones is not easy. Since I moved away from using celery (its broken timzone handling beeing one of the reasons ^^), I unfortunately do not have the time to provide a full PR for this.
Just wanted to report this bug, since I stumbled upon it while browsing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Chronial you are right, this has already been corrected by other contributors in master/latest release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry for digging up this old PR. I came here via the mention on #4006 and didn't realize how old this PR was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem @Chronial thanks for the feedback.