#4950·celery

RPC with status or ready leaves Unacked messages in queue

Author: christensonbCreated Aug 2, 2018Updated Sep 13, 2026
LabelsIssue Type: Bug ReportComponent: RPC Results Backend

If the job is done and job.ready() or job.status is accessed the job.get() will not acknowledge the message in the amqp queue.

"""
    pip install:
        celery[redis]~=4.1
    start workers with:
        python -m celery worker -A celery_example --concurrency 10
    start master with:
        python -m celery_example master
"""
import sys
import time
from celery import Celery

amqp_uri = 'usr:pwd@localhost/testing'
DELAY = 0.3

app = Celery('celery_example',
             broker=f'pyamqp://{amqp_uri}',
             backend=f'rpc://{amqp_uri}')


@app.task()
def add(x, y):
    time.sleep(DELAY)
    return x + y


def main():
    for i in range(10000):
        print("Adding: %s + %s"%(i, i))
        job = add.delay(i, i)

        print("Status: %s"%job.status) # does not cause unacked
        print("Ready: %s"%job.ready()) # does not cause unacked

        time.sleep(DELAY+1) # wait for job to be done

        print("Status: %s"%job.status) # causes unacked
        print("Ready: %s"%job.ready()) # causes unacked

        result = job.get(timeout=DELAY+1)
        print(" "*20+"-- Received Answer: %s"%result)
        assert result == i + i


if __name__ == '__main__' and sys.argv[-1] == 'master':
    main()