celery-once
celery-once copied to clipboard
Suggestion: Allow checking if task is pending without enqueuing it
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?
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.
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.