Skip to content

Commit

Permalink
fix long period task will never be triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
daydaychen authored and chentiantian committed Jan 19, 2024
1 parent 00f0a5c commit 28ea74e
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions django_celery_beat/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,8 @@ def __init__(self, model, app=None):
self.model = model

if not model.last_run_at:
model.last_run_at = self._default_now()
# if last_run_at is not set and
# model.start_time last_run_at should be in way past.
# This will trigger the job to run at start_time
# and avoid the heap block.
if self.model.start_time:
model.last_run_at = model.last_run_at \
- datetime.timedelta(days=365 * 30)
model.last_run_at = self._default_now() \
- datetime.timedelta(days=365 * 30)

self.last_run_at = model.last_run_at

Expand Down

0 comments on commit 28ea74e

Please sign in to comment.