Warning

This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: parallel.controller.hub

The IPython Controller Hub with 0MQ

This is the master object that handles connections from engines and clients, and monitors traffic through the various queues.

3 Classes

class IPython.parallel.controller.hub.EngineConnector(*args, **kw)

Bases: IPython.utils.traitlets.HasTraits

A simple object for accessing the various zmq connections of an object. Attributes are: id (int): engine ID uuid (unicode): engine UUID pending: set of msg_ids stallback: tornado timeout for stalled registration

class IPython.parallel.controller.hub.HubFactory(**kwargs)

Bases: IPython.parallel.factory.RegistrationFactory

The Configurable for setting up a Hub.

__init__(**kwargs)
client_url(channel)

return full zmq url for a named client channel

engine_url(channel)

return full zmq url for a named engine channel

init_hub()

construct Hub object

class IPython.parallel.controller.hub.Hub(**kwargs)

Bases: IPython.kernel.zmq.session.SessionFactory

The IPython Controller Hub with 0MQ connections

Parameters:

loop: zmq IOLoop instance

session: Session object

<removed> context: zmq context for creating new connections (?)

queue: ZMQStream for monitoring the command queue (SUB)

query: ZMQStream for engine registration and client queries requests (ROUTER)

heartbeat: HeartMonitor object checking the pulse of the engines

notifier: ZMQStream for broadcasting engine registration changes (PUB)

db: connection to db for out of memory logging of commands

NotImplemented

engine_info: dict of zmq connection information for engines to connect

to the queues.

client_info: dict of zmq connection information for engines to connect

to the queues.

__init__(**kwargs)

# universal: loop: IOLoop for creating future connections session: streamsession for sending serialized data # engine: queue: ZMQStream for monitoring queue messages query: ZMQStream for engine+client registration and client requests heartbeat: HeartMonitor object for tracking engines # extra: db: ZMQStream for db connection (NotImplemented) engine_info: zmq address/protocol dict for engine connections client_info: zmq address/protocol dict for client connections

connection_request(client_id, msg)

Reply with connection addresses for clients.

db_query(client_id, msg)

Perform a raw query on the task record database.

dispatch_monitor_traffic(msg)

all ME and Task queue messages come through here, as well as IOPub traffic.

dispatch_query(msg)

Route registration requests and queries from clients.

finish_registration(heart)

Second half of engine registration, called after our HeartMonitor has received a beat from the Engine’s Heart.

get_history(client_id, msg)

Get a list of all msg_ids in our DB records

get_results(client_id, msg)

Get the result of 1 or more messages.

handle_heart_failure(heart)

handler to attach to heartbeater. called when a previously registered heart fails to respond to beat request. triggers unregistration

handle_new_heart(heart)

handler to attach to heartbeater. Called when a new heart starts to beat. Triggers completion of registration.

purge_results(client_id, msg)

Purge results from memory. This method is more valuable before we move to a DB based message storage mechanism.

queue_status(client_id, msg)

Return the Queue status of one or more targets.

If verbose, return the msg_ids, else return len of each type.

Keys:

  • queue (pending MUX jobs)
  • tasks (pending Task jobs)
  • completed (finished jobs from both queues)
register_engine(reg, msg)

Register a new engine.

resubmit_task(client_id, msg)

Resubmit one or more tasks.

save_iopub_message(topics, msg)

save an iopub message into the db

save_task_request(idents, msg)

Save the submission of a task.

save_task_result(idents, msg)

save the result of a completed task.

shutdown_request(client_id, msg)

handle shutdown request.

unregister_engine(ident, msg)

Unregister an engine that explicitly requested to leave.

2 Functions

IPython.parallel.controller.hub.empty_record()

Return an empty dict with all record keys.

IPython.parallel.controller.hub.init_record(msg)

Initialize a TaskRecord based on a request.