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