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

DatabaseScheduler: Reload config when Cron or Interval was changed #352

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions djcelery/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class CrontabSchedule(models.Model):
_('month of year'), max_length=64, default='*',
)

no_changes = False

class Meta:
verbose_name = _('crontab')
verbose_name_plural = _('crontabs')
Expand Down Expand Up @@ -182,6 +184,8 @@ class PeriodicTasks(models.Model):
ident = models.SmallIntegerField(default=1, primary_key=True, unique=True)
last_update = models.DateTimeField(null=False)

no_changes = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this line here? Maybe it should be moved to IntervalSchedule?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to re-use the same trigger for PeriodicTask when IntervalSchedule or CrontabSchedule has some change.

So, without this, you need to restart de celery beat to reload configuration of CrontabSchedule or IntervalSchedule, or you need to trigger some modification on PeriodicTask to reload configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems reasonable.
But this line is defined on PeriodicTasks class. I don't think it is needed here, since the signal is not connected with sender=PeriodicTasks. Meanwhile, IntervalSchedule doesn't have no_changes.


objects = managers.ExtendedManager()

@classmethod
Expand Down Expand Up @@ -289,6 +293,11 @@ def schedule(self):
signals.pre_delete.connect(PeriodicTasks.changed, sender=PeriodicTask)
signals.pre_save.connect(PeriodicTasks.changed, sender=PeriodicTask)

signals.pre_delete.connect(PeriodicTasks.changed, sender=IntervalSchedule)
signals.pre_save.connect(PeriodicTasks.changed, sender=IntervalSchedule)

signals.pre_delete.connect(PeriodicTasks.changed, sender=CrontabSchedule)
signals.pre_save.connect(PeriodicTasks.changed, sender=CrontabSchedule)

class WorkerState(models.Model):
hostname = models.CharField(_('hostname'), max_length=255, unique=True)
Expand Down