cameronmaske / celery-once

Celery Once allows you to prevent multiple execution and queuing of celery tasks.
https://pypi.python.org/pypi/celery_once/
BSD 2-Clause "Simplified" License
661 stars 90 forks source link

get_key function return different key for same function. #120

Open huanghugo opened 4 years ago

huanghugo commented 4 years ago

I'm use celery_once=3.0.0 in my project.

I have a task like:

@celery.task(base=QueueOnce)
def calculate_something():

But when I run the task on second time, it always throw AlreadyQueued exception. Seems like the key didn't been delete after this function ends.

So I create a class

class TestQueueOnce(QueueOnce):

and call get_key and print the key in apply_async and after_return

I found the key is different!

in after_return, the key is app.worker.analyze_tasks.calculate_something_args-()_kwargs-{} in apply_async, the key is app.worker.analyze_tasks.calculate_something