PyZMQ Documentation

Table Of Contents

Previous topic

devices.basedevice

Next topic

eventloop.ioloop

This Page

devices.monitoredqueuedevice

Module: devices.monitoredqueuedevice

MonitoredQueue classes and functions.

Authors

  • MinRK
  • Brian Granger

Classes

MonitoredQueue

class zmq.devices.monitoredqueuedevice.MonitoredQueue(in_type, out_type, mon_type, in_prefix='in', out_prefix='out')

Threadsafe MonitoredQueue object.

Warning as with most ‘threadsafe’ Python objects, this is only threadsafe as long as you do not use private methods or attributes. Private names are prefixed with ‘_’, such as ‘self._setup_socket()’.

See zmq.devices.Device for most of the spec. This subclass adds a <method>_mon version of each <method>_{in|out} method, for configuring the monitor socket.

A MonitoredQueue is a 3-socket ZMQ Device that functions just like a QUEUE, except each message is also sent out on the monitor socket.

If a message comes from in_sock, it will be prefixed with ‘in’. If it comes from out_sock, it will be prefixed with ‘out’

A PUB socket is perhaps the most logical for the mon_socket, but it is not restricted.

bind_in(addr)

Enqueue ZMQ address for binding on in_socket.

See zmq.Socket.bind for details.

bind_mon(addr)

Enqueue ZMQ address for binding on mon_socket.

See zmq.Socket.bind for details.

bind_out(iface)

Enqueue ZMQ address for binding on out_socket.

See zmq.Socket.bind for details.

connect_in(addr)

Enqueue ZMQ address for connecting on in_socket.

See zmq.Socket.connect for details.

connect_mon(addr)

Enqueue ZMQ address for connecting on mon_socket.

See zmq.Socket.bind for details.

connect_out(iface)

Enqueue ZMQ address for connecting on out_socket.

See zmq.Socket.connect for details.

static context_factory()

Returns a global Context instance.

Most single-threaded applications have a single, global Context. Use this method instead of passing around Context instances throughout your code.

A common pattern for classes that depend on Contexts is to use a default argument to enable programs with multiple Contexts but not require the argument for simpler applications:

class MyClass(object):
def __init__(self, context=None):
self.context = context or Context.instance()
join(timeout=None)

wait for me to finish, like Thread.join.

Reimplemented appropriately by sublcasses.

run()
setsockopt_in(opt, value)

Enqueue setsockopt(opt, value) for in_socket

See zmq.Socket.setsockopt for details.

setsockopt_mon(opt, value)

Enqueue setsockopt(opt, value) for mon_socket

See zmq.Socket.setsockopt for details.

setsockopt_out(opt, value)

Enqueue setsockopt(opt, value) for out_socket

See zmq.Socket.setsockopt for details.

start()

Start the device. Override me in subclass for other launchers.

MonitoredQueueBase

class zmq.devices.monitoredqueuedevice.MonitoredQueueBase(in_type, out_type, mon_type, in_prefix='in', out_prefix='out')

Base class for overriding methods.

bind_mon(addr)

Enqueue ZMQ address for binding on mon_socket.

See zmq.Socket.bind for details.

connect_mon(addr)

Enqueue ZMQ address for connecting on mon_socket.

See zmq.Socket.bind for details.

run()
setsockopt_mon(opt, value)

Enqueue setsockopt(opt, value) for mon_socket

See zmq.Socket.setsockopt for details.

ProcessMonitoredQueue

class zmq.devices.monitoredqueuedevice.ProcessMonitoredQueue(in_type, out_type, mon_type, in_prefix='in', out_prefix='out')

MonitoredQueue in a Process. See MonitoredQueue for more.

bind_in(addr)

Enqueue ZMQ address for binding on in_socket.

See zmq.Socket.bind for details.

bind_mon(addr)

Enqueue ZMQ address for binding on mon_socket.

See zmq.Socket.bind for details.

bind_out(iface)

Enqueue ZMQ address for binding on out_socket.

See zmq.Socket.bind for details.

connect_in(addr)

Enqueue ZMQ address for connecting on in_socket.

See zmq.Socket.connect for details.

connect_mon(addr)

Enqueue ZMQ address for connecting on mon_socket.

See zmq.Socket.bind for details.

connect_out(iface)

Enqueue ZMQ address for connecting on out_socket.

See zmq.Socket.connect for details.

context_factory

alias of Context

join(timeout=None)
launcher = None
run()
setsockopt_in(opt, value)

Enqueue setsockopt(opt, value) for in_socket

See zmq.Socket.setsockopt for details.

setsockopt_mon(opt, value)

Enqueue setsockopt(opt, value) for mon_socket

See zmq.Socket.setsockopt for details.

setsockopt_out(opt, value)

Enqueue setsockopt(opt, value) for out_socket

See zmq.Socket.setsockopt for details.

start()

ThreadMonitoredQueue

class zmq.devices.monitoredqueuedevice.ThreadMonitoredQueue(in_type, out_type, mon_type, in_prefix='in', out_prefix='out')

MonitoredQueue in a Thread. See MonitoredQueue for more.

bind_in(addr)

Enqueue ZMQ address for binding on in_socket.

See zmq.Socket.bind for details.

bind_mon(addr)

Enqueue ZMQ address for binding on mon_socket.

See zmq.Socket.bind for details.

bind_out(iface)

Enqueue ZMQ address for binding on out_socket.

See zmq.Socket.bind for details.

connect_in(addr)

Enqueue ZMQ address for connecting on in_socket.

See zmq.Socket.connect for details.

connect_mon(addr)

Enqueue ZMQ address for connecting on mon_socket.

See zmq.Socket.bind for details.

connect_out(iface)

Enqueue ZMQ address for connecting on out_socket.

See zmq.Socket.connect for details.

static context_factory()

Returns a global Context instance.

Most single-threaded applications have a single, global Context. Use this method instead of passing around Context instances throughout your code.

A common pattern for classes that depend on Contexts is to use a default argument to enable programs with multiple Contexts but not require the argument for simpler applications:

class MyClass(object):
def __init__(self, context=None):
self.context = context or Context.instance()
join(timeout=None)
launcher = None
run()
setsockopt_in(opt, value)

Enqueue setsockopt(opt, value) for in_socket

See zmq.Socket.setsockopt for details.

setsockopt_mon(opt, value)

Enqueue setsockopt(opt, value) for mon_socket

See zmq.Socket.setsockopt for details.

setsockopt_out(opt, value)

Enqueue setsockopt(opt, value) for out_socket

See zmq.Socket.setsockopt for details.

start()