-
Notifications
You must be signed in to change notification settings - Fork 434
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
Removing tasks from celery_beat config doesn't remove them from database. #248
Comments
Thanks @rrauenza! I'm new to this project but looking at your solution, it seems like maybe this could be something that should be more clear in the django-celery-beat documentation? I'm guessing that there may be a case where that data is needed for auditing purposes but then also it would be good to warn people that there could be build up. I will look and see if this is referenced in the docs already and if not, then I will try and find a place to add a mention of this behavior. |
maybe this helps to alleviate this issue #389? |
+1 |
please elaborate. plus 1 comment isn't helpful |
This is still happening. I removed my task function and removed the task from |
@richardARPANET You haven't described how you've integrated the workaround. Did you add and enable the alternate scheduler |
Same problem, deleted all about task, but it still tries to execute each time I start celery |
One way was to import logging
from django_celery_beat import models
logger = logging.getLogger(__name__)
def clear_celery_beat_tables():
try:
logger.info('Clearing all celery beat tables')
models.CrontabSchedule.objects.all().delete()
models.SolarSchedule.objects.all().delete()
models.ClockedSchedule.objects.all().delete()
models.IntervalSchedule.objects.all().delete()
models.PeriodicTask.objects.all().delete()
models.PeriodicTasks.objects.all().delete()
logger.info('Celery beat tables cleared')
except AttributeError:
logger.info('Error while clearing celery tables') Then call this when your application starts (before Celery app init ideally) |
Summary:
I had the (obviously now incorrect) assumption that if I used
celery_beat
in the celery config dictionary to define my schedule that if I changed it (renamed or removed items) that the database schedule would be synced to the removals.I don't expect this issue to be fixed -- I'm just documenting it for other people looking for an answer.
Exact steps to reproduce the issue:
celery_beat
in configcelery_beat
Detailed information
I've documented a work around here, creating my own scheduler:
https://stackoverflow.com/q/56047284/2077386
I'm posting it here for anyone else to use -- and in case you want to add it to the project.
This scheduler assumes you are using
celery_beat
in your celery config exclusively to define your schedule as it would wipe out any tasks not included in there. It could theoretically wipe out tasks from other apps (see above I whitelist celery.*).So.... I don't think it's actually a great candidate for the project.
The text was updated successfully, but these errors were encountered: