8.1.2. Message

Implement a basic message encoder/decoder where the payload can be any pickable Python object.

Message are encoded as a header followed by a pickled payload where the header contains the length of the pickled payload encoded as a 4-byte unsigned integer.

To decode a message, first read HEADER_LENGTH bytes from the stream, then decode the header to get the next number of bytes to read, finally read them and decode the payload.

class sidita.Message.StandardMessageStream(input_stream, output_stream)[source]

Bases: sidita.Message.MessageStream

read(length)[source]
write(data)[source]
class sidita.Message.AsyncMessageStream(input_stream, output_stream, timeout=None)[source]

Bases: sidita.Message.MessageStream

read(length)[source]
receive()[source]
write(data)[source]
sidita.Message.encode_message(message)[source]
sidita.Message.decode_header(header)[source]
sidita.Message.decode_message(pickled_message)[source]