@receiver(pre_save, sender=ToDoAlert)
def schedule_todo_alert_send(sender, **kwargs):
if kwargs.get("raw"):
return
todo_alert = kwargs["instance"]
current_celery_task_id = todo_alert.celery_task_id
if current_celery_task_id is not None:
# Revoking tasks only works with amqp, redis and mongodb for now (celery 2.5)
control.revoke(current_celery_task_id)
result = send_todo_alert.apply_async(args=[todo_alert], eta=todo_alert.time.astimezone(get_default_timezone()))
todo_alert.celery_task_id = result.task_id
What if the notification is 10 days in the future? I guess you would have a problem, because a message queue isn't meant to store things for so long? Or is that the reason that you used MongoDB?