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

Rethinking total_run_count reset for one-off tasks in is_due #733

Open
AryanHamedani opened this issue Feb 18, 2024 Discussed in #730 · 1 comment
Open

Rethinking total_run_count reset for one-off tasks in is_due #733

AryanHamedani opened this issue Feb 18, 2024 Discussed in #730 · 1 comment

Comments

@AryanHamedani
Copy link

Discussed in #730

Originally posted by AryanHamedani February 13, 2024
The ModelEntry class in django-celery-beat includes a logic snippet that resets total_run_count to 0 for one-off tasks after they run once:

# ONE OFF TASK: Disable one off tasks after they've ran once
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
    self.model.no_changes = False  # Mark the model entry as changed
    self.model.save()
    # Don't recheck
    return schedules.schedstate(False, NEVER_CHECK_TIMEOUT)

This behavior raises a discussion point:
- Preserving run history:
While disabling the task makes sense, resetting total_run_count loses valuable information about its execution history. Understanding past execution is crucial for debugging, auditing, and future scheduling decisions.
- Redundant state update:
Is disabling the task sufficient to prevent future runs? Does the reset of total_run_count add unnecessary complexity?
- Alternative solutions:
Are there better ways to handle one-off tasks after they run once, while still maintaining a record of their execution?

I propose this discussion to solicit community input on:

  • The rationale behind the current behavior.
  • Potential drawbacks of losing the execution history.
  • Alternative approaches that balance task disablement with run history preservation.
  • Feasibility and contributions to addressing this potential improvement.
  • I believe this discussion can lead to a more intuitive and informative way to manage one-off tasks in django-celery-beat.
@alirafiei75
Copy link

i have the same problem with this. total run count is useless in this way.

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

2 participants