简体   繁体   中英

Using Celery, how do you remove tasks from “Ready” state when using acks_late=True?

In Celery, if you use acks_late=True in the tasks, it will not acknowledge the task immediately acknowledge the task until the task is finished.

I have a very simple task that just prints out the message. If I send a bunch of messages, the worker will print out the message, but they do not get removed. Rabbit still reports them as "Ready." "Ready" and "Total" will have the same number (and keeps incrementing) but "Unacked" always falls back to 0 as the workers finish.

So it appears that indeed, once the task finishes, they're acked, but how do you remove them from the "Ready" state?

from celery import Celery

broker_uri = 'amqp://.....'

celery_app = Celery('my_name', broker=broker_uri, backend='rpc://')

@celery_app.task(name='bam.add', acks_late=True)
def add(filename):
    print(filename)

Also, if I quit/restart the worker, it doesn't grab the messages in the Ready state. Why is this and is there any way to grab them?

Thanks!

If this search comes up for anyone, it has to do with the backend= parameter. Some tutorials include this parameter, but don't explain the consequences. It persists the results from the task as a message back into RabbitMQ.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM