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

Keep meta data around task, even after disabled. #352

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion django_celery_beat/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class PeriodicTaskAdmin(admin.ModelAdmin):
}),
('Schedule', {
'fields': ('interval', 'crontab', 'solar', 'clocked',
'start_time', 'last_run_at', 'one_off'),
'start_time', 'last_run_at','total_run_count', 'one_off'),
'classes': ('extrapretty', 'wide'),
}),
('Arguments', {
Expand All @@ -148,6 +148,7 @@ class PeriodicTaskAdmin(admin.ModelAdmin):
)
readonly_fields = (
'last_run_at',
'total_run_count'
)

def changelist_view(self, request, extra_context=None):
Expand Down
2 changes: 0 additions & 2 deletions django_celery_beat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,6 @@ def save(self, *args, **kwargs):
self.routing_key = self.routing_key or None
self.queue = self.queue or None
self.headers = self.headers or None
if not self.enabled:
Copy link
Member

Choose a reason for hiding this comment

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

does this create any regreassion?

self.last_run_at = None
self._clean_expires()
self.validate_unique()
super(PeriodicTask, self).save(*args, **kwargs)
Expand Down
1 change: 0 additions & 1 deletion django_celery_beat/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def is_due(self):
if self.model.one_off and self.model.enabled \
and self.model.total_run_count > 0:
self.model.enabled = False
self.model.total_run_count = 0 # Reset
Copy link
Member

Choose a reason for hiding this comment

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

is it backward-incompatible?

self.model.no_changes = False # Mark the model entry as changed
self.model.save()
return schedules.schedstate(False, None) # Don't recheck
Expand Down