Skip to content
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

How to update PeriodicTask after updating tasks in app.conf.beat_schedule #757

Open
jlariza opened this issue Jun 13, 2024 · 3 comments
Open

Comments

@jlariza
Copy link

jlariza commented Jun 13, 2024

Summary:

Good day,

I've noticed that PeriodicTask instances are not updated after app.conf.beat_schedule is updated. For example, this is my original app.conf.beat_schedule:

app.conf.beat_schedule = {
    "send-pending-messages": {
        "task": "app.messages.tasks.send_pending_pessages",
        "schedule": crontab(hour=6, minute=0, day_of_month="25"),
    },
}

It creates a PeriodicTask with this crontab: 0 6 25 * * (m/h/dM/MY/d).

Then, after some changes in my code, I update the beat_schedule to

app.conf.beat_schedule = {
    "send-pending-messages": {
        "task": "app.messages.tasks.send_pending_pessages",
        "schedule": crontab(hour=5, minute=0, day_of_month="10"),
    },
}

However, after this change, the PeriodicTask is still with this crontab: 0 6 25 * * (m/h/dM/MY/d) when it should be 0 5 10 * * (m/h/dM/MY/d).

How may I make sure that the database will be updated if I modified the app.conf.beat_schedule configuration?

Thank you,

  • Celery Version: 5.4.0
  • Celery-Beat Version: 2.6.0
@jlariza
Copy link
Author

jlariza commented Jun 13, 2024

At the end, I had to delete the PeriodicTask instances from the database and restart the app to force it to create the new ones correctly.

However, it would be nice to have a mechanism to force a database refresh without having to delete the database (specially in the cases where not all PeriodicTask are saved in the beat_schedule. Also, it would solve the problem with the deleted tasks reported in #706

Thank you,

@m-r-k-f
Copy link

m-r-k-f commented Jul 10, 2024

Hi jlariza,
I had the same issue. But I fount a good solution: #768
Have fun.

@kylebebak
Copy link

kylebebak commented Jul 11, 2024

This is really basic functionality -- if the records in django_celery_beat_periodictask (the DB) don't match what's in beat_schedule (application code), this library is broken

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

3 participants