I want to create delayed task and if there would be some conditions, I need to find that task and revoke it.
This is how I create task:
notify_before_departure.apply_async(
args=(user.fcm_registration_token, booking.bus_stop_from.title,),
eta=notification_time,
)
So is there any attribute apply_async
has where I can define my custom ID which can later be used to revoke this exact task? Something like this:
# create task
notify_before_departure.apply_async(
args=(user.fcm_registration_token, booking.bus_stop_from.title,),
eta=notification_time,
custom_id=booking.id
)
# revoke if needed
from celery.task.control import revoke
revoke(booking.id, terminate=True)