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
662 stars 90 forks source link

Feature/return task #32

Closed szandara closed 8 years ago

szandara commented 9 years ago

I worked on a feature to prevent tasks with the same id to run at the same time. Celery does not have protection against this. If you run two same tasks with the same id, both will equally be processed. I think this use case is not so common but it is critical in my new project.

Apart from integrity, the main reason for this is the possibility to retrieve the AsyncResult of the running task and use that to listen to its execution and/or get its result.

Apart from me, I could find at least another interested user. http://stackoverflow.com/questions/27771229/reuse-results-for-celery-tasks

I have extended celery_once since the idea behind is just the same.

I created a completely new task QueueOnceId type because I think that the variety of parameters of QueueOnce do not really apply well to QueueOnceId, so in order to avoid confusion I separated them. Also, mixing the two would change the behavior of QueueOnce but it can be done. I have already done some prototyping where QueueOnce has a new failure type so no need for a new task. If you prefer that way, just tell me and I will work on it.