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

Validate schedule objects on save for faster, more informative failures #484

Open
stevecj opened this issue Dec 17, 2021 · 6 comments
Open

Comments

@stevecj
Copy link

stevecj commented Dec 17, 2021

Summary:

When an instance of a schedule model (e.g. CrontabSchedule) has a field with an invalid value, no error is displayed, and the task is (silently) not added to the current schedule. If an exception occurred when trying to create the record, then the problem would be much easier to detect and then much easier to diagnose once detected.

  • Celery Version: 5.2.1
  • Celery-Beat Version: 2.2.1

Exact steps to reproduce the issue:

  1. Create a CrontabSchedule instance with an invalid value in any of its crontab fields.
  2. Create a PeriodicTask instance with the above CrontabSchedule instance as its .crontab value.
  3. See that the task never runs.
@auvipy
Copy link
Member

auvipy commented Dec 17, 2021

is this from the discussion you opened?

@stevecj
Copy link
Author

stevecj commented Dec 17, 2021

It is related to that. Yes. I was able to solve the problem that I opened the discussion about, but I it was very complicated to track down the cause.

@auvipy
Copy link
Member

auvipy commented Dec 18, 2021

ok, can you check this PR #478?

@lvelvee
Copy link

lvelvee commented Dec 18, 2021

def all_as_schedule(self):
debug('DatabaseScheduler: Fetching database schedule')
s = {}
for model in self.Model.objects.enabled():
try:
s[model.name] = self.Entry(model, app=self.app)
except ValueError:
pass

@stevecj
Copy link
Author

stevecj commented Dec 21, 2021

@lvelvee Thanks for pasting that code that I should have included in my original description of the problem.

@auvipy I might be wrong, but I don't see that PR #478 addresses this issue of mine — though I really like what you're doing there.

@auvipy
Copy link
Member

auvipy commented Dec 22, 2021

ok if you are welcome to come with a proposed improvement with a failing test

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