I am working on a parallel-able tasks with Python3 and celery. I like to divide it into several chunks, so those cost of communications over the network will be saved. However, the celery document does not reveal enough details on how to call the result chunks. Tried different ways and they do not work as I expected. My code segment is as follows:
@app.task(name='pl.startregret')
def startregret(**kwargs):
items = list(zip(range(1000), range(1000)))
chunk = regretclick.chunks(items, 10)
print(chunk)
for c in chunk:
print(c)
@app.task(name='pl.regretclick')
def regretclick(x,y):
print('got it.')
return x + y
I read some codes and thought that chunk in my code should be a generator. However, the printout shows
[2014-10-15 13:12:15,930: WARNING/Worker-2] args
[2014-10-15 13:12:15,931: WARNING/Worker-2] subtask_type
[2014-10-15 13:12:15,931: WARNING/Worker-2] kwargs
[2014-10-15 13:12:15,931: WARNING/Worker-2] immutable
[2014-10-15 13:12:15,931: WARNING/Worker-2] options
[2014-10-15 13:12:15,931: WARNING/Worker-2] task
Any suggestions on the right way to call the chunks?
Thanks,
Update: I have read the source code and tried chunk(). Looks like the only issue now the default queue is used instead of the queue defined in celeryconfig.