Skip to content

Custom schedule type is not being used #696

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

Open
sdrabblescripta opened this issue Nov 28, 2023 · 0 comments
Open

Custom schedule type is not being used #696

sdrabblescripta opened this issue Nov 28, 2023 · 0 comments

Comments

@sdrabblescripta
Copy link

Summary:

Custom schedule type is not being used, so is_due is never called.

  • Celery Version: 5.3.5
  • Celery-Beat Version: 2.5.0

Exact steps to reproduce the issue:

from app import is_last_day_of_month
CELERY_BEAT_SCHEDULE = {
        'foo': {
                'options': {'queue': DATABASE_NAME},
                'kwargs': {'creator_name': 'system'},
                'task': 'tasks.foo', # it doesn't matter what the task is, the issue is with the schedule class
                'schedule': is_last_day_of_month(run_every=120),
        },
    }

Last day of month func. Note that the `is_due` method is never executed - this is because the schedule class is always `schedule` and never `is_last_day_of_month`.

from celery import schedules

class is_last_day_of_month(schedules.schedule):

    def is_due(self, last_run_at: datetime) -> tuple[bool, datetime]:
        now = date.today()
        day_range = calendar.monthrange(now.year, now.month)
        eom = now.replace(day=day_range[1])
        return (now.day == eom.day, 86400)

Detailed information

Appears to be caused by this:

 class IntervalSchedule(models.Model):

   ...

    def schedule(self):
        return schedules.schedule(
            timedelta(**{self.period: self.every}),
            nowfun=lambda: make_aware(now())
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant