sleap.message#

Module with classes for sending and receiving messages between processes.

These use ZMQ pub/sub sockets.

Most of the time you’ll want the PairedSender and PairedReceiver. These support a “handshake” to confirm connection. Without an initial handshake there’s a good chance early messages will be dropped.

Each message is either dictionary or dictionary + numpy ndarray.

class sleap.message.BaseMessageParticipant(address: str = 'tcp://127.0.0.1:9001', context: Optional[zmq.sugar.context.Context] = None, socket: Optional[zmq.sugar.socket.Socket] = None)[source]#

Base class for simple Sender and Receiver.

class sleap.message.Receiver(address: str = 'tcp://127.0.0.1:9001', context: Optional[zmq.sugar.context.Context] = None, socket: Optional[zmq.sugar.socket.Socket] = None, message_queue: List[Any] = NOTHING)[source]#

Receives messages from corresponding Sender.

check_message(timeout: int = 10, fresh: bool = False) Any[source]#

Attempt to receive a single message.

check_messages(timeout: int = 10, times_to_check: int = 10) List[dict][source]#

Attempt to receive multiple messages.

This method allows us to keep up with the messages by getting multiple messages that have been sent since the last check. It keeps checking until limit is reached or we check without getting any messages back.

push_back_message(message)[source]#

Act like we didn’t receive this message yet.

class sleap.message.Sender(address: str = 'tcp://127.0.0.1:9001', context: Optional[zmq.sugar.context.Context] = None, socket: Optional[zmq.sugar.socket.Socket] = None)[source]#

Publishes messages to corresponding Receiver.

send_array(header_data: dict, A: numpy.ndarray, flags=0, copy=True, track=False)[source]#

Sends dictionary + numpy ndarray.

send_dict(data: dict)[source]#

Sends dictionary.