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: Add how many tasks are permitted #63

Open michelpf opened 6 years ago

michelpf commented 6 years ago

I have some use cases when is good to control how many allowed tasks are permitted. I workaround giving some parameters, to have this control, for example:

  sender.add_periodic_task(10, cleaning_file.s("1"), name='Cleaning Worker 1')
  sender.add_periodic_task(10, cleaning_file.s("3"), name='Cleaning Worker 2')

Would be nice to have that kind of configuration such as a parameter called _maxtask:

@app.task(base=QueueOnce, once={'graceful': True, 'max_task': 2}, max_retries=0)
def cleaning_file(key="default"):