bag.interface.zmqwrapper
This module defines various wrapper around ZMQ sockets.
Module Contents
Classes
A class that interacts with a ZMQ dealer socket. |
|
A class that interacts with a ZMQ router socket. |
- class bag.interface.zmqwrapper.ZMQDealer(port, pipeline=100, host='localhost', log_file=None)[source]
Bases:
object
A class that interacts with a ZMQ dealer socket.
a dealer socket is an asynchronous socket that can issue multiple requests without needing to wait for an reply. This class encapsulates the ZMQ socket details and provide more convenient API to use.
- Parameters:
- send_obj(obj)[source]
Sends a python object using pickle serialization and zlib compression.
- Parameters:
obj (any) – the object to send.
- class bag.interface.zmqwrapper.ZMQRouter(port=None, min_port=5000, max_port=9999, pipeline=100, log_file=None)[source]
Bases:
object
A class that interacts with a ZMQ router socket.
a router socket is an asynchronous socket that can receive multiple requests without needing to issue an reply. This class encapsulates the ZMQ socket details and provide more convenient API to use.
- Parameters:
port (int or None) – the port to connect to. If None, then a random port between min_port and max_port will be chosen.
min_port (int) – the minimum random port number (inclusive).
max_port (int) – the maximum random port number (exclusive).
pipeline (int) – number of messages allowed in a pipeline. Only affects file transfer performance.
log_file (str or None) – the log file. None to disable logging.
- send_obj(obj, addr=None)[source]
Sends a python object using pickle serialization and zlib compression.
- Parameters:
obj (any) – the object to send.
addr (str or None) – the address to send the object to. If None, send to last sender.