I want to send messages to celery and when it reaches let's say 100 messages i want celery to execute them in batches. This is a common scenario if I want to commit in batches to a database.
For this purpose while googling around i found this link: for doing batches with celery: http://celery.readthedocs.org/en/latest/reference/celery.contrib.batches.html
My problem is that in the example there is no obvious way to get the data submitted to the task
for instance lets say that we submit one by one some messages with:
task.apply_async((message,), link_error=error_handler.s())
and then we have the following task implementation:
@celery.task(name="process.data", base=Batches, flush_every=100, flush_interval=1)
def process_messages(requests):
for request in requests:
print request /// how I can take the message data submitted in my task for process?
Is there any alternative way to achieve batches with celery? Thank you
celery.contrib.batches
has been removed in Celery 4 :-(. Ref: docs.celeryproject.org/en/latest/…. – Foss