5

I'm having trouble understanding the Celery queue and revokes. My main question is how to revoke (stop from executing) tasks that are already in the queue if a new task with the same name and arguments is created. so in pseudo-code

new_task_to_be_added = some_task(1,2)
if exists some_task in queue where some_task.args = (1,2):
    remove such task from queue
new_task_to_be_added.add_to_queue()

this is connected to password reset mechanism - User clicks 'create temporary password' and has 5 minutes to use this password to create a new - permanent - password. If the new password is not set in this time the account should be locked. But if after lets say 4 minutes user creates a new temporary password he should again have 5 minutes to change it but the "lock account" task will trigger in 1 minute - I want to stop that and always only use the newest task (with the same parameters)

this is not a copy of: Revoke celery tasks with same args/kwargs this is actually reversed problem

quqa123
  • 605
  • 6
  • 15

0 Answers0