-
Notifications
You must be signed in to change notification settings - Fork 435
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
Fix the time calculation problem caused by start_time #844
base: main
Are you sure you want to change the base?
Conversation
Changes:
Why is this change needed?
Impact:
Suggested Solution:
Question
|
Changed to draft until the CI passes |
I'll take the time to fix this code |
I found that After implementing the corresponding method, I will call it within |
I created a method for the PeriodicTask model to calculate the accurate start_time, and it calls is_due to calculate the delay when the task is crontab. This way, I don't need to modify the Celery source code, and I fixed this issue in django-celery-beat. I'm not sure if this kind of modification follows the standard practices? |
I ran the unit tests for django-celery-beat, and they pass on my Mac but fail on Windows. I would like to use the official CI to run the tests. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #844 +/- ##
==========================================
+ Coverage 87.42% 87.85% +0.42%
==========================================
Files 32 32
Lines 954 963 +9
Branches 76 77 +1
==========================================
+ Hits 834 846 +12
+ Misses 102 100 -2
+ Partials 18 17 -1 ☔ View full report in Codecov by Sentry. |
I discovered a bug in my code while trying to write unit tests. I will fix it later and conduct the corresponding tests. |
In the process of supplementing the test cases, I found that my code still has some time zone issues, which I will modify tomorrow. |
I think I solved the time zone issue. |
I will re review it tomorrow |
Description:
This pull request addresses an issue when setting a specific
start_time
for scheduled tasks indjango-celery-beat
. When thestart_time
is set to a future time, Celery treats this time as part of theevent_t
tuple, specifically theevent_t.time
field. As a result, Celery continues to check whether the task has reached its execution condition, which can cause unwanted behavior.Changes:
is_due
method indjango-celery-beat/schedulers.py
to prevent tasks with a futurestart_time
from being processed before thestart_time
is reached.Expected Behavior:
The
event.time
should be generated based on thestart_time
, the current time, and the task's schedule, ensuring that tasks with a futurestart_time
do not appear at the top of the heap or get processed until their execution time is reached. This approach allows other tasks, such as interval-based tasks, to execute without being blocked.issue