I want to implement task cancellation with cleanup process on Celery + RabbitMQ broker. How can I get "REVOKED" status of current task in Celery worker?
# tasks.py -- celery worker
from celery import Celery
app = Celery('tasks', broker='amqp://guest@localhost//')
@app.task
def add(x, y):
for i in range(0, 10):
time.sleep(1)
# I want check here for cleanup.
return x + y
# caller.py
from tasks import add
result = add.delay(4, 4)
result.revoke()
Celery supports Abortable tasks, but it only works the database backend.
Python 3.4.1 / Celery 3.1.17 / RabbitMQ 3.4.4