celery-once icon indicating copy to clipboard operation
celery-once copied to clipboard

Suggestion: Allow checking if task is pending without enqueuing it

Open harrybiddle opened this issue 6 years ago • 2 comments

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?

harrybiddle avatar May 02 '18 08:05 harrybiddle

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.

cameronmaske avatar Apr 15 '19 11:04 cameronmaske

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.

harrybiddle avatar Apr 18 '19 10:04 harrybiddle