-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Celery.timezone: try tzlocal.get_localzone() before using LocalTimezone #9862
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9862 +/- ##
==========================================
- Coverage 78.70% 78.64% -0.06%
==========================================
Files 153 153
Lines 19258 19268 +10
Branches 2561 2562 +1
==========================================
- Hits 15157 15154 -3
- Misses 3803 3816 +13
Partials 298 298
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
16d4c6f to
b39b3dd
Compare
Nusnus
left a comment
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.
The integration tests are broken right now, so take note the CI will fail.
Fix/workaround in progress.
fc92abe to
dba2a2e
Compare
auvipy
left a comment
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.
we should add unit test coverage for the proposed changes
|
I'm not sure what kind of test I should add. I'm assuming there are already tests for the local timezone and they pass with the changes. I could perhaps make a test that patches |
|
that would be fine. |
dba2a2e to
c99da5e
Compare
|
These timezone tests were already there
I added two tests explicitly for the local timezone
|
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.
Pull Request Overview
This PR replaces Celery's custom LocalTimezone implementation with the tzlocal library to obtain the local system timezone. The change provides better timezone detection using standard IANA timezone names instead of Celery's custom UTC offset-based representation.
Key changes:
- Adds
tzlocalas a new dependency for improved local timezone detection - Updates the
_Zone.localproperty to usetzlocal.get_localzone()with fallback toLocalTimezone - Adds comprehensive test coverage for the new timezone detection logic
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| celery/utils/time.py | Implements the core timezone detection logic using tzlocal with exception handling and fallback |
| t/unit/app/test_app.py | Adds test cases for successful tzlocal usage and fallback scenarios when tzlocal fails |
| setup.cfg | Adds tzlocal dependency to RPM requirements |
| requirements/default.txt | Adds tzlocal to default Python requirements |
auvipy
left a comment
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.
do you want to add any additional tests or documentation for this?
|
This PR is complete for me. The change is fully test-covered and no need for docs imo. It is still the local time zone as before. The only difference is that thanks to the IANA name it will show up nicer (human readable) in Flower after this is merged https://github.com/mher/flower/pull/1351/files. |
Closes #9861
Use
tzlocal.get_localzone()and fall back toLocalTimezone()for the local system timezone.