Код: Выделить всё
@celery_app.task(base=DefaultTask)
def square_batch(k):
return [x*x for x in k]
# return [x * x for [x] in k]
< /code>
вызов задачи < /p>
@app.get("/chunk")
def cnk():
data=(range(100))
job=square_batch.chunks(data,10)
task=job.apply_async()
return {"task submitted with id":task.id}
Подробнее здесь: https://stackoverflow.com/questions/796 ... uare-batch