django-q icon indicating copy to clipboard operation
django-q copied to clipboard

Deleting a schedule before it triggers.

Open aaronn opened this issue 2 years ago • 3 comments

Is there any way to prevent a Schedule from triggering before it's run?

timer = timezone.now() + timedelta(seconds=10)

schedule(
                MY_TASK,
                arg_1,
                schedule_type=Schedule.ONCE,
                next_run=timer,
                repeats=-1,
                user_id=user.id,
 )

In this scenario, I'd expect that deleting the schedule prevents it from being run, but it seems like it runs anyways:

Schedule.objects.filter(func=MY_TASK, args=f"{arg_1}").delete()

aaronn avatar Dec 28 '21 22:12 aaronn

Right I already noticed.. So what I did:

from django_q.models import Failure,OrmQ,Schedule
Schedule.objects.all().delete()
Failure.objects.all().delete()
OrmQ.objects.all().delete()

rokdd avatar Feb 23 '22 21:02 rokdd

I'll try this-- but what are you using to filter ORMQ and failure down?

aaronn avatar Feb 23 '22 22:02 aaronn

Because I experience that the task are stucking in the other models and thats why I delete them there as well. When you only want to delete for a specific task then you should filter before because you remove all of them.

rokdd avatar Feb 24 '22 14:02 rokdd