django-q
django-q copied to clipboard
Deleting a schedule before it triggers.
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()
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()
I'll try this-- but what are you using to filter ORMQ and failure down?
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.