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 (usingeventlet.hubs.trampoline()
) if azmq.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.
With flags=NOBLOCK, this raises
ZMQError
if no messages have arrived; otherwise, this waits until a message arrives. SeePoller
for more general non-blocking I/O.- flags : int
- 0 or NOBLOCK.
- 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 or 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 (including if NOBLOCK is set and no new messages have arrived).
-
send
(msg, flags=0, copy=True, track=False)¶ Send a single zmq message frame on this socket.
This queues the message to be sent by the IO thread at a later time.
With flags=NOBLOCK, this raises
ZMQError
if the queue is full; otherwise, this waits until space is available. SeePoller
for more general non-blocking I/O.- data : bytes, Frame, memoryview
- The content of the message. This can be any object that provides the Python buffer API (i.e. memoryview(data) can be called).
- flags : int
- 0, NOBLOCK, SNDMORE, or 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)
- routing_id : int
- For use with SERVER sockets
- group : str
- For use with RADIO sockets
- 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 (including if NOBLOCK is set and the outgoing queue is full).
Changed in version 17.0: DRAFT support for routing_id and group arguments.
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 |