Pyro5.protocol — Pyro wire protocol

The pyro wire protocol structures.

Pyro - Python Remote Objects. Copyright by Irmen de Jong (

Wire messages contains of a fixed size header, an optional set of annotation chunks, and then the payload data. This class doesn’t deal with the payload data: (de)serialization and handling of that data is done elsewhere. Annotation chunks are only parsed.

The header format is:

0x00   4s  4   'PYRO' (message identifier)
0x04   H   2   protocol version
0x06   B   1   message type
0x07   B   1   serializer id
0x08   H   2   message flags
0x0a   H   2   sequence number   (to identify proper request-reply sequencing)
0x0c   I   4   data length   (max 4 Gb)
0x10   I   4   annotations length (max 4 Gb, total of all chunks, 0 if no annotation chunks present)
0x14   16s 16  correlation uuid
0x24   H   2   (reserved)
0x26   H   2   magic number 0x4dc5
total size: 0x28 (40 bytes)

After the header, zero or more annotation chunks may follow, of the format:

4s  4   annotation id (4 ASCII letters)
I   4   chunk length  (max 4 Gb)
B   x   annotation chunk databytes
class Pyro5.protocol.ReceivingMessage(header, payload=None)

Wire protocol message that was received.


Parses (annotations processing) and adds payload data to a received message.

static validate(data)

Checks if the message data looks like a valid Pyro message, if not, raise an error.

class Pyro5.protocol.SendingMessage(msgtype, flags, seq, serializer_id, payload, annotations=None)

Wire protocol message that will be sent.

static ping(pyroConnection)

Convenience method to send a ‘ping’ message and wait for the ‘pong’ response

Pyro5.protocol.log_wiredata(logger, text, msg)

logs all the given properties of the wire message in the given logger

Pyro5.protocol.recv_stub(connection, accepted_msgtypes=None)

Receives a pyro message from a given connection. Accepts the given message types (None=any, or pass a sequence). Also reads annotation chunks and the actual payload data.


(int) The various message type identifiers


(int) Various bitflags that specify the characteristics of the message, can be bitwise or-ed together