ait.core.server.process module

class ait.core.server.process.PluginsProcess(namespace)

Bases: object

PluginsProcess allows a set of plugins to be run in a separate process. Since plugins are all greenlets, the process runs them within a cleaned-up gevent context (thanks to GIPC).

An instance is first populated with a set of PluginConfig’s instances.

When the spawn_process() method is called, GIPC creates a new process. This process creates a fresh ZeroMQ Context, instantiates all managed Plugins (using the PluginConfigs), and then runs the Plugins within a gevent-space that is isolated from other processes.

__init__(namespace)

Constructor

Params:
namespace: Namespace for the child-process
abort()

Aborts the spawned child process associated with the Plugin

Returns: boolean - True if process was terminated, False otherwise

add_plugin_info(plugin_info)

Adds a PluginConfig instance to be managed

Params:
plugin_info: Instance of PluginConfig
Raises:
RuntimeError if the process is already running
static create_plugin(plugin_info, zmq_context)

Builds and initializes Plugin instance, passing the stored arguments for inputs, outputs, ZMQ args, and other keywords arguments

Params:
plugin_info: Instance of PluginConfig zmq_context: ZeroMQ context to be used by Plugin
Returns:
Plugin - New Plugin instance
get_plugin_names(use_short_names=True)

Returns a list of plugin names (short versions) managed by instance Returns: List of plugin names

get_plugin_outputs(use_short_names=True)

Return dict of plugin name to list of outputs, where outputs will subscribe to the plugin. The map keys represent either the plugin’s fullname or shortname, depending on the value of use_short_names

Args:
use_short_names: boolean
If true, plugin key will be short-name, otherwise full name
Returns:
Map of plugin names to list of outputs names which should subscribe to plugin
static load_plugins(namespace, plugin_info_list)
spawn_process()

Spawns the child-process which will build and run the associated Plugins

Raises:
RuntimeError if this method is called more than once
static start_and_join_all(namespace, plugin_list)

Start all of the plugins in the list. Then wait for them to complete with a call to gevent.joinall()

Args:
namespace: Process namespace (used for logging) plugin_list: List of Plugin’s to be started
static start_plugins_process(namespace, plugin_info_list)

Creates and runs Plugins built from the plugin-info list. This method is expected to run within its own process.

Params:
namespace: Namespace for the child-process plugin_info_list: List of PluginConfig’s
static subscribe_plugins_to_inputs(plugin_list)

Subscribe all plugins to their associated inputs only. This is handled separately from outputs because the plugin which is performing the subscription to the input resides in this process. Output subscriptions must occur in the process where the stream resides, which is the server’s process

Args:
plugin_list: List of Plugin’s
static update_process_name(namespace)

Renames the process title associated with current process. Without this, process has the same title as original server.

Args:
namespace: AIT process namespace