Giter Club home page Giter Club logo

Comments (3)

cameronmaske avatar cameronmaske commented on August 15, 2024

@mafrosis celery_once is designed to be a extension on top of celery that prevent's multiple tasks executing at the same time.
If you have requirements that mean you shouldn't be running or queuing repeated tasks, that where celery_once becomes useful.

In your example above, having a concurrency of 1 doesn't prevent you from queuing multiple tasks with the same args.
For example, if you ran the following task...

@task()
def slow_convert():
   sleep(10)

like so...

for _ in range(100):
   slow_convert.delay()

It would be queued up 100 times, and preformed 100 times, 1 by 1.
If you declared it like so...

@celery.task(base=QueueOnce)
def slow_convert():
    sleep(10)

An AlreadyQueued exception will be raised after the first loop.

>>> for _ in range(100):
>>>   slow_convert.delay()
Traceback (most recent call last):
    ..
AlreadyQueued()

It would of been queued once, and preformed queued. Until it is run, no other tasks like that can be queued.
Depending on the application, that can be very useful! :)
Hope that answers the question!

from celery-once.

mafrosis avatar mafrosis commented on August 15, 2024

Thanks! I can see that AlreadyQueued could be useful in some applications.

from celery-once.

mafrosis avatar mafrosis commented on August 15, 2024

Thinking about it a bit - it should be possible to use your AMQP broker only to provide the locking mechanism, removing the need for Redis. Querying the broker but not acknowledge the message will leave it available for other consumers (although I've never done that with celery!)

from celery-once.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.