ZMQBroker

class Cauldron.zmq.broker.ZMQBroker(name, address, pub_address, sub_address, mon_address, context=None, timeout=1.0, heartbeat=True)[source] [edit on github]

Bases: threading.Thread

A broker object for handling ZMQ Messaging patterns

Attributes Summary

ident Thread identifier of this thread or None if it has not been started.
name A string used for identification purposes only.

Methods Summary

check([config, timeout, ctx, address]) Check for the existence of a router at the configured address.
cleanup(socket) docstring for cleanup
close() Close thread-local sockets.
connect(address[, mode]) Connect the frontend and backend sockets.
daemon([config, daemon]) Starts a broker in a subprocess using multiprocessing.
from_config(config[, name]) Generate a new broker using the configuration provided.
getName()
get_service(service) Try to get a service.
isAlive() Return whether the thread is alive.
isDaemon()
is_alive() Return whether the thread is alive.
join([timeout]) Wait until the thread terminates.
prepare() Thread local way to prepare connections.
respond() Respond to a single message on each socket.
respond_inquiry(message, socket) Respond to an inquiry.
run() Run method for threads.
serve([config, name]) Make a broker which runs in the current thread until stopped.
setDaemon(daemonic)
setName(name)
setup([config, timeout, daemon]) Ensure that a broker is running.
start() Start the thread’s activity.
stop([timeout]) Stop the responder.
sub([config, daemon]) Starts a broker in either a subprocess or a thread.
thread([config, daemon]) Serve in a thread.

Attributes Documentation

ident

Thread identifier of this thread or None if it has not been started.

This is a nonzero integer. See the thread.get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.

name

A string used for identification purposes only.

It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.

Methods Documentation

classmethod check(config=None, timeout=2.0, ctx=None, address=None)[source] [edit on github]

Check for the existence of a router at the configured address.

cleanup(socket)[source] [edit on github]

docstring for cleanup

close()[source] [edit on github]

Close thread-local sockets.

connect(address, mode='ROUTER')[source] [edit on github]

Connect the frontend and backend sockets.

classmethod daemon(config=None, daemon=True)[source] [edit on github]

Starts a broker in a subprocess using multiprocessing.

classmethod from_config(config, name='ConfiguredBroker')[source] [edit on github]

Generate a new broker using the configuration provided.

Returns the broker object in its inital state.

getName() [edit on github]
get_service(service)[source] [edit on github]

Try to get a service.

isAlive() [edit on github]

Return whether the thread is alive.

This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.

isDaemon() [edit on github]
is_alive() [edit on github]

Return whether the thread is alive.

This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.

join(timeout=None) [edit on github]

Wait until the thread terminates.

This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.

When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call isAlive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.

When the timeout argument is not present or None, the operation will block until the thread terminates.

A thread can be join()ed many times.

join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.

prepare()[source] [edit on github]

Thread local way to prepare connections.

respond()[source] [edit on github]

Respond to a single message on each socket.

respond_inquiry(message, socket)[source] [edit on github]

Respond to an inquiry.

run()[source] [edit on github]

Run method for threads.

classmethod serve(config=None, name='ServerBroker')[source] [edit on github]

Make a broker which runs in the current thread until stopped.

This method is blocking.

setDaemon(daemonic) [edit on github]
setName(name) [edit on github]
classmethod setup(config=None, timeout=2.0, daemon=True)[source] [edit on github]

Ensure that a broker is running.

If check() can find a broker, no broker is started. Otherwise a broker is started using sub().

start() [edit on github]

Start the thread’s activity.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.

stop(timeout=None)[source] [edit on github]

Stop the responder.

classmethod sub(config=None, daemon=True)[source] [edit on github]

Starts a broker in either a subprocess or a thread.

If none of the ZMQ broker addresses use the inproc:// zmq protocol then the broker will be started in a subprocess. Otherwise, the broker will start in the current process using the global ZMQ context.

classmethod thread(config=None, daemon=True)[source] [edit on github]

Serve in a thread.