eventlet.green.zmq – ØMQ support

The zmq module wraps the Socket and Context found in pyzmq to be non blocking

eventlet.green.zmq.Context(io_threads=1, **kwargs)

Subclass of zmq.core.context.Context

class eventlet.green.zmq.Socket(context, socket_type)

Bases: zmq.sugar.socket.Socket

Green version of :class:`zmq.core.socket.Socket

The following three methods are always overridden:
  • send
  • recv
  • getsockopt

To ensure that the zmq.NOBLOCK flag is set and that sending or receiving is deferred to the hub (using eventlet.hubs.trampoline()) if a zmq.EAGAIN (retry) error is raised

For some socket types, the following methods are also overridden:
  • send_multipart
  • recv_multipart
recv(flags=0, copy=True, track=False)

Receive a message.

flags
: int
Any supported flag: NOBLOCK. If NOBLOCK is set, this method will raise a ZMQError with EAGAIN if a message is not ready. If NOBLOCK is not set, then this method will block until a message arrives.
copy
: bool
Should the message be received in a copying or non-copying manner? If False a Frame object is returned, if True a string copy of message is returned.
track
: bool
Should the message be tracked for notification that ZMQ has finished with it? (ignored if copy=True)
msg
: bytes, Frame
The received message frame. If copy is False, then it will be a Frame, otherwise it will be bytes.
ZMQError
for any of the reasons zmq_msg_recv might fail.
send(data, flags=0, copy=True, track=False)

Send a message on this socket.

This queues the message to be sent by the IO thread at a later time.

data
: object, str, Frame
The content of the message.
flags
: int
Any supported flag: NOBLOCK, SNDMORE.
copy
: bool
Should the message be sent in a copying or non-copying manner.
track
: bool
Should the message be tracked for notification that ZMQ has finished with it? (ignored if copy=True)
None
: if copy or not track
None if message was sent, raises an exception otherwise.
MessageTracker
: if track and not copy
a MessageTracker object, whose pending property will be True until the send is completed.
TypeError
If a unicode object is passed
ValueError
If track=True, but an untracked Frame is passed.
ZMQError
If the send does not succeed for any reason.

zmq – The pyzmq ØMQ python bindings

pyzmq [1] Is a python binding to the C++ ØMQ [2] library written in Cython [3]. The following is auto generated pyzmq's from documentation.

[1]http://github.com/zeromq/pyzmq
[2]http://www.zeromq.com
[3]http://www.cython.org