chunks
Partition of tasks into chunks of size n.
Constructor
Signature
def chunks(
task: Any,
it: Iterable,
n: int,
**options: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| task | Any | The task to be executed in chunks. |
| it | Iterable | The iterable containing the data to be partitioned. |
| n | int | The size of each chunk. |
| **options | dict | Additional execution and message options. |
Signature
def chunks(
task: string|Signature,
it: iterable,
n: int
)
Parameters
| Name | Type | Description |
|---|---|---|
| task | `string | Signature` |
| it | iterable | The iterable of arguments to be partitioned into chunks |
| n | int | The number of items to include in each chunk |
Methods
from_dict()
@classmethod
def from_dict(
d: dict,
app: [Celery](../app/base/celery.md?sid=celery_app_base_celery)
) - > [chunks](chunks.md?sid=celery_canvas_chunks)
Creates a chunks instance from a dictionary representation containing task arguments and options.
Parameters
| Name | Type | Description |
|---|---|---|
| d | dict | The dictionary containing 'kwargs' (task, it, n) and 'options' for the signature |
| app | [Celery](../app/base/celery.md?sid=celery_app_base_celery) | The Celery application instance to associate with this signature |
Returns
| Type | Description |
|---|---|
[chunks](chunks.md?sid=celery_canvas_chunks) | A new chunks signature instance initialized with the provided dictionary data |
apply_async()
@classmethod
def apply_async(
args: tuple,
kwargs: dict,
**opts: dict
) - > [AsyncResult](../result/asyncresult.md?sid=celery_result_asyncresult)
Dispatches the chunked tasks to the broker for asynchronous execution.
Parameters
| Name | Type | Description |
|---|---|---|
| args | tuple | Additional positional arguments for the task execution |
| kwargs | dict | Additional keyword arguments for the task execution |
| **opts | dict | Routing and execution options for the Celery broker |
Returns
| Type | Description |
|---|---|
[AsyncResult](../result/asyncresult.md?sid=celery_result_asyncresult) | A result object that tracks the execution of the underlying task group |
group()
@classmethod
def group() - > [group](group.md?sid=celery_canvas_group)
Converts the chunks instance into a group of starmap signatures.
Returns
| Type | Description |
|---|---|
[group](group.md?sid=celery_canvas_group) | A Celery group containing individual task signatures for each data partition |
apply_chunks()
@classmethod
def apply_chunks(
task: string|Signature,
it: iterable,
n: int,
app: [Celery](../app/base/celery.md?sid=celery_app_base_celery)
) - > [AsyncResult](../result/asyncresult.md?sid=celery_result_asyncresult)
Creates a chunks instance and executes it immediately.
Parameters
| Name | Type | Description |
|---|---|---|
| task | `string | Signature` |
| it | iterable | The data to be partitioned |
| n | int | The size of each partition |
| app | [Celery](../app/base/celery.md?sid=celery_app_base_celery) | The Celery application instance to use for execution |
Returns
| Type | Description |
|---|---|
[AsyncResult](../result/asyncresult.md?sid=celery_result_asyncresult) | The result of the executed chunked task group |