Skip to main content

TaskMessage

Create task message in protocol 2 format.

def TaskMessage(
name: str,
id: str = None,
args: Sequence = (),
kwargs: Mapping = None,
callbacks: Sequence[Signature] = None,
errbacks: Sequence[Signature] = None,
chain: Sequence[Signature] = None,
shadow: str = None,
utc: bool = None,
**options: Any
) - > Mock

Create task message in protocol 2 format.

Parameters

NameTypeDescription
namestrThe fully qualified name of the task to be executed.
idstr = NoneThe unique identifier for the task; if not provided, a new UUID is generated.
argsSequence = ()Positional arguments to be passed to the task function.
kwargsMapping = NoneKeyword arguments to be passed to the task function.
callbacksSequence[Signature] = NoneA list of task signatures to be executed upon successful completion of the task.
errbacksSequence[Signature] = NoneA list of task signatures to be executed if the task encounters an error.
chainSequence[Signature] = NoneA list of subsequent task signatures to be executed in a chain.
shadowstr = NoneAn alternative name to use for the task in logs and monitoring tools.
utcbool = NoneFlag indicating whether timestamps should use UTC.
**optionsAnyAdditional header fields or execution options to include in the message metadata.

Returns

TypeDescription
MockA mock message object containing the serialized task payload, headers, and metadata required for Celery protocol 2 communication.