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

Suggestion: Allow checking if task is pending without enqueuing it #70

Open harrybiddle opened 6 years ago

harrybiddle commented 6 years ago

I have a class with a method that asynchronously executes a maintenance operation of sorts asynchronously. I want certain methods of this class to raise an exception if this maintenance operation is in progress. celery-once looks ideal for my use case, except that I would like to be able to query whether the task is in progress without enqueuing it.

Looking at the code, this should just be a case of pulling out all except the last line of QueueOnce .apply_async into another method, say "already_queued".

Would there be interest in a PR for this?

cameronmaske commented 5 years ago

Hey @harrybiddle Sorry for my delay in following up on this.

This is a neat idea, and I think it is valuable for other's use cases. If you'd like to submit a PR or someone else would like to submit a PR with the already_queued functionality, I'd do my best to get it merged/released.

harrybiddle commented 5 years ago

Thanks for the reply! I've since managed to get around this issue entirely by avoiding celery-once for this use case, so I think it's unfortunately unlikely I'll be able to find time to put in this PR.