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

Manually execute PeriodicTask? #678

Open
ssandr1kka opened this issue Sep 15, 2023 · 0 comments
Open

Manually execute PeriodicTask? #678

ssandr1kka opened this issue Sep 15, 2023 · 0 comments

Comments

@ssandr1kka
Copy link

  • Celery Version: 5.3.4
  • Celery-Beat Version: 2.5.0

Hello, for testing purposes, is there a way to manually execute PeriodicTask?

        buffer = instance.updated_at + timedelta(hours=24)
        task_name = f"task_{instance.id}"
        schedule, _ = ClockedSchedule.objects.get_or_create(clocked_time=buffer)
        PeriodicTask.objects.get_or_create(
            name=task_name,
            defaults={
                "task": "pointing to the task",
                "args": [instance.id],
                "kwargs": {},
                "clocked": schedule,
                "one_off": True,
            }
        )

So is there a way to manually execute this now?
I know I can do task.apply() however that is not testing my whether my PeriodicTask instance is set properly, I want to test whether args, kwargs are set properly

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

1 participant