taskiq icon indicating copy to clipboard operation
taskiq copied to clipboard

Requeue Takes the inital delay as original call

Open chiragkatare opened this issue 1 year ago • 1 comments

I am using rabbitmq with taskiq, My use case is to delay a job and inside the task worker i am using context to requeue the job ,

There its again delaying the job for the original delay.

chiragkatare avatar Jan 10 '25 12:01 chiragkatare

I'm not 100 sure what is the problem, but if the problem is that the requeued task was sent with the same delay as the original, then most probably it's because the desired delay is stored in labels. You can delete the delay label before requeue to avoid delayed execution for the second time. Like this:

@broker.task
async def example(context: Context):
    context.message.labels.pop("delay")
    await context.requeue()

s3rius avatar Jan 28 '25 20:01 s3rius