Celery execute task with a batch of messages
For anyone that will find this post useful after many trial and errors I have managed to take the data out of the SimplRequest object in the following way:
When you submit your data with the following way:
func.delay(data)
from the request object you get the args attribute which is a list with the data:
request.args[0]
request.args[1]
etc.
If you submit your data with the following way:
func.apply_async((), {'data': data}, link_error=error_handler.s())
then data are available as a dictionary in kwargs:
request.kwargs['data']
Finally, as the example shows we need to do a loop into all requests to gather the data batch
for r in requests:
data = r.kwargs['data']
It would be nice for the examples in page of the documentation (here) to be updated with a more simple and clear example