ait.core.server.client module

class ait.core.server.client.PortInputClient(zmq_context, zmq_proxy_xsub_url='tcp://*:5559', zmq_proxy_xpub_url='tcp://*:5560', **kwargs)

Bases: ait.core.server.client.ZMQClient, gevent.server.DatagramServer

This is the parent class for all inbound streams which receive messages on a port. It opens a UDP port for receiving messages, listens for them, and calls the process method on all messages received.

__init__(zmq_context, zmq_proxy_xsub_url='tcp://*:5559', zmq_proxy_xpub_url='tcp://*:5560', **kwargs)

Initialize self. See help(type(self)) for accurate signature.

handle(packet, address)
class ait.core.server.client.PortOutputClient(zmq_context, zmq_proxy_xsub_url='tcp://*:5559', zmq_proxy_xpub_url='tcp://*:5560', **kwargs)

Bases: ait.core.server.client.ZMQInputClient

This is the parent class for all outbound streams which publish to a port. It opens a UDP port to publish to and publishes outgoing message data to this port.

__init__(zmq_context, zmq_proxy_xsub_url='tcp://*:5559', zmq_proxy_xpub_url='tcp://*:5560', **kwargs)
Parameters:
  • args – The arguments passed to the run function.
  • kwargs – The keyword arguments passed to the run function.
  • run (callable) – The callable object to run. If not given, this object’s _run method will be invoked (typically defined by subclasses).

Changed in version 1.1b1: The run argument to the constructor is now verified to be a callable object. Previously, passing a non-callable object would fail after the greenlet was spawned.

Changed in version 1.3b1: The GEVENT_TRACK_GREENLET_TREE configuration value may be set to a false value to disable spawn_tree_locals, spawning_greenlet, and spawning_stack. The first two will be None in that case, and the latter will be empty.

Changed in version 1.5: Greenlet objects are now more careful to verify that their parent is really a gevent hub, raising a TypeError earlier instead of an AttributeError later.

Changed in version 20.12.1: Greenlet objects now function as context managers. Exiting the with suite ensures that the greenlet has completed by joining the greenlet (blocking, with no timeout). If the body of the suite raises an exception, the greenlet is killed with the default arguments and not joined in that case.

publish(msg)

Publishes input message with client name as the topic if the topic parameter is not provided.

Publishes input message with topic as the topic if the topic parameter is provided. Topic can be an arbitrary string.

class ait.core.server.client.ZMQClient(zmq_context, zmq_proxy_xsub_url='tcp://*:5559', zmq_proxy_xpub_url='tcp://*:5560', **kwargs)

Bases: object

This is the base ZeroMQ client class that all streams and plugins inherit from. It opens a ZMQ PUB socket to publish messages to and publishes to it.

__init__(zmq_context, zmq_proxy_xsub_url='tcp://*:5559', zmq_proxy_xpub_url='tcp://*:5560', **kwargs)

Initialize self. See help(type(self)) for accurate signature.

process(input_data, topic=None)

This method must be implemented by all streams and plugins that inherit from ZMQClient. It is called whenever a message is received.

Params:

input_data: message received by client topic: name of component message received from, if received

through ZeroMQ
Raises:
NotImplementedError since not implemented in base parent class
publish(msg, topic=None)

Publishes input message with client name as the topic if the topic parameter is not provided.

Publishes input message with topic as the topic if the topic parameter is provided. Topic can be an arbitrary string.

class ait.core.server.client.ZMQInputClient(zmq_context, zmq_proxy_xsub_url='tcp://*:5559', zmq_proxy_xpub_url='tcp://*:5560', **kwargs)

Bases: ait.core.server.client.ZMQClient, gevent._gevent_cgreenlet.Greenlet

This is the parent class for all streams and plugins with input streams. It opens a ZeroMQ SUB socket for receiving ZMQ messages from the input streams it is subscribed to and stays open to receiving those messages, calling the process method on all messages received.

__init__(zmq_context, zmq_proxy_xsub_url='tcp://*:5559', zmq_proxy_xpub_url='tcp://*:5560', **kwargs)
Parameters:
  • args – The arguments passed to the run function.
  • kwargs – The keyword arguments passed to the run function.
  • run (callable) – The callable object to run. If not given, this object’s _run method will be invoked (typically defined by subclasses).

Changed in version 1.1b1: The run argument to the constructor is now verified to be a callable object. Previously, passing a non-callable object would fail after the greenlet was spawned.

Changed in version 1.3b1: The GEVENT_TRACK_GREENLET_TREE configuration value may be set to a false value to disable spawn_tree_locals, spawning_greenlet, and spawning_stack. The first two will be None in that case, and the latter will be empty.

Changed in version 1.5: Greenlet objects are now more careful to verify that their parent is really a gevent hub, raising a TypeError earlier instead of an AttributeError later.

Changed in version 20.12.1: Greenlet objects now function as context managers. Exiting the with suite ensures that the greenlet has completed by joining the greenlet (blocking, with no timeout). If the body of the suite raises an exception, the greenlet is killed with the default arguments and not joined in that case.