This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 5.0.

Message Compression - kombu.compression

Compression utilities.

Encoding/decoding

kombu.compression.compress(body, content_type)[source]

Compress text.

Parameters
  • body (AnyStr) – The text to compress.

  • content_type (str) – mime-type of compression method to use.

kombu.compression.decompress(body, content_type)[source]

Decompress compressed text.

Parameters
  • body (AnyStr) – Previously compressed text to uncompress.

  • content_type (str) – mime-type of compression method used.

Registry

kombu.compression.encoders()[source]

Return a list of available compression methods.

kombu.compression.get_encoder(t)[source]

Get encoder by alias name.

kombu.compression.get_decoder(t)[source]

Get decoder by alias name.

kombu.compression.register(encoder, decoder, content_type, aliases=None)[source]

Register new compression method.

Parameters
  • encoder (Callable) – Function used to compress text.

  • decoder (Callable) – Function used to decompress previously compressed text.

  • content_type (str) – The mime type this compression method identifies as.

  • aliases (Sequence[str]) – A list of names to associate with this compression method.