Serialization

Serializers and compression of Celery messages and results.

JSON is built in. MessagePack and YAML need an extra (pip install celery-cloud[msgpack] / celery-cloud[yaml]). pickle is not supported on purpose: unpickling a message from a queue executes arbitrary code.

exception celery_cloud.serialization.SerializationError[source]

Bases: Exception

The data cannot be decoded or encoded with the requested format.

celery_cloud.serialization.decompress(data: bytes, compression: str | None) → bytes[source]

Undo the compression of a message body (gzip/zlib, bzip2 and lzma).

celery_cloud.serialization.dumps(value: Any, serializer: str = 'json') → bytes[source]

Encode value with serializer (json, msgpack or yaml).

Values the format cannot hold (datetime, Decimal, UUID…) are stored as their str(), so a task that ran is never reported as failed over its return value.

celery_cloud.serialization.loads(data: bytes | str, content_type: str) → Any[source]

Decode data written with the serializer of content_type.