cis_interface.drivers package

Subpackages

Submodules

cis_interface.drivers.AsciiFileInputDriver module

class cis_interface.drivers.AsciiFileInputDriver.AsciiFileInputDriver(name, args, skip_AsciiFile=False, **kwargs)[source]

Bases: cis_interface.drivers.FileInputDriver.FileInputDriver

Class that sends lines from an ASCII file.

Parameters:
  • name (str) – Name of the queue that messages should be sent to.
  • args (str or dict) – Path to the file that messages should be read from or dictionary containing the filepath and other keyword arguments to be passed to the created AsciiFile object.
  • skip_AsciiFile (bool, optional) – If True, the AsciiFile instance is not created. Defaults to False.
  • **kwargs – Additional keyword arguments are passed to parent class.
file_kwargs

dict – Arguments used to create AsciiFile instance.

file

AsciiFile.AsciiFile – Associated special class for ASCII file.

close_file()[source]

Close the file.

eof_msg

str – Message indicating end of file.

run()[source]

Run the driver. The file is opened and then data is read from the file and sent to the message queue until eof is encountered or the file is closed.

cis_interface.drivers.AsciiFileOutputDriver module

class cis_interface.drivers.AsciiFileOutputDriver.AsciiFileOutputDriver(name, args, skip_AsciiFile=False, **kwargs)[source]

Bases: cis_interface.drivers.FileOutputDriver.FileOutputDriver

Class to handle output line by line to an ASCII file.

Parameters:
  • name (str) – Name of the output queue to receive messages from.
  • args (str or dict) – Path to the file that messages should be written to or dictionary containing the filepath and other keyword arguments to be passed to the created AsciiFile object.
  • skip_AsciiFile (bool, optional) – If True, the AsciiFile instance is not created. Defaults to False.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
file_kwargs

dict – Arguments used to create AsciiFile instance.

file

AsciiFile.AsciiFile – Associated special class for ASCII file.

close_file()[source]

Close the file.

eof_msg

str – Message indicating end of file.

run()[source]

Run the driver. The driver will open the file and write receieved messages to the file as they are received until the file is closed.

cis_interface.drivers.AsciiTableInputDriver module

class cis_interface.drivers.AsciiTableInputDriver.AsciiTableInputDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.AsciiFileInputDriver.AsciiFileInputDriver

Class to handle input from an ASCII table.

Parameters:
  • name (str) – Name of the input queue to send messages to.
  • args (str or dict) – Path to the file that messages should be read from or dictionary containing the filepath and other keyword arguments to be passed to the created AsciiTable object.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in additon to parent class’s):
file (AsciiTable.AsciiTable): Associated special class for
ASCII table.
as_array (bool): If True, the table contents are sent all at once as an
array. Defaults to False if not set in args dict.
run()[source]

Run the driver. The file is opened and then data is read from the file and sent to the message queue until eof is encountered or the file is closed.

cis_interface.drivers.AsciiTableOutputDriver module

class cis_interface.drivers.AsciiTableOutputDriver.AsciiTableOutputDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.AsciiFileOutputDriver.AsciiFileOutputDriver

Class to handle output of received messages to an ASCII table.

Parameters:
  • name (str) – Name of the output queue to receive messages from.
  • args (str or dict) – Path to the file that messages should be written to or dictionary containing the filepath and other keyword arguments to be passed to the created AsciiTable object.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in additon to parent class’s):
file (AsciiTable.AsciiTable): Associated special class for
ASCII table.
as_array (bool): If True, the table contents are received all at once
as an array. Defaults to False if not set in args dict.
run()[source]

Run the driver. The format string is received then output is written to the file as it is received from the message queue until eof is encountered or the file is closed.

cis_interface.drivers.Driver module

class cis_interface.drivers.Driver.Driver(name, yml={}, namespace=None, rank=None, workingDir=None)[source]

Bases: threading.Thread

Base class for all drivers.

Parameters:
  • name (str) – Driver name.
  • yml (dict, optional) – Dictionary of yaml specification options for this driver. Defaults to empty dict.
  • namespace (str, optional) – Namespace for set of drivers running together. If not provided, the environment variable ‘PSI_NAMESPACE’ is used.
  • rank (int, optional) – Rank of the integration. Defaults to None.
  • workingDir (str, optional) – Working directory. If not provided, the current working directory is used.
name

str – Driver name.

sleeptime

float – Time that driver should sleep for when sleep called.

longsleep

float – Time that the driver will sleep for when waiting for longer tasks to complete (10x longer than sleeptime).

timeout

float – Maximum time that should be spent waiting on a process.

yml

dict – Dictionary of yaml specification options for this driver.

namespace

str – Namespace for set of drivers running together.

rank

int – Rank of the integration.

workingDir

str – Working directory.

critical(fmt_str='', *args)[source]

Log a critical message that is prepended with the driver class and name.

Parameters:
  • fmt_str (str, optional) – Format string.
  • *args – Additional arguments are formated using the format string.
debug(fmt_str='', *args)[source]

Log a debug message that is prepended with the driver class and name.

Parameters:
  • fmt_str (str, optional) – Format string.
  • *args – Additional arguments are formated using the format string.
display(fmt_str='', *args)[source]

Log a message at level 1000 that is prepended with the driver class and name. These messages will always be printed.

Parameters:
  • fmt_str (str, optional) – Format string.
  • *args – Additional arguments are formated using the format string.
error(fmt_str='', *args)[source]

Log an error message that is prepended with the driver class and name.

Parameters:
  • fmt_str (str, optional) – Format string.
  • *args – Additional arguments are formated using the format string.
exception(fmt_str='', *args)[source]

Log an exception message that is prepended with the driver class ane name.

Parameters:
  • fmt_str (str, optional) – Format string.
  • *args – Additional arguments are formated using the format string.
graceful_stop()[source]

Gracefully stop the driver.

info(fmt_str='', *args)[source]

Log an info message that is prepended with the driver class and name.

Parameters:
  • fmt_str (str, optional) – Format string.
  • *args – Additional arguments are formated using the format string.
logger_prefix

Prefix to add to logger messages.

on_exit()[source]

Processes that should be run when the driver exits.

printStatus()[source]

Print the driver status.

run()[source]

Run something in a seperate thread.

sched_task(t, func, args=[], kwargs={})[source]

Schedule a task that will be executed after a certain time has elapsed.

Parameters:
  • t (float) – Number of seconds that should be waited before task is executed.
  • func (object) – Function that should be executed.
  • args (list, optional) – Arguments for the provided function. Defaults to [].
  • kwargs (dict, optional) – Keyword arguments for the provided function. Defaults to {}.
sleep(t=None)[source]

Have the driver sleep for some period of time.

Parameters:t (float, optional) – Time that driver should sleep for. If not provided, the attribute ‘sleeptime’ is used.
stop()[source]

Stop the driver.

terminate()[source]

Stop the driver, without attempting to allow it to finish.

wait()[source]

Wait until model finish to return.

warn(fmt_str='', *args)[source]

Log a warning message that is prepended with the driver class and name.

Parameters:
  • fmt_str (str, optional) – Format string.
  • *args – Additional arguments are formated using the format string.

cis_interface.drivers.FileInputDriver module

class cis_interface.drivers.FileInputDriver.FileInputDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.IODriver.IODriver

Class that sends messages read from a file.

Parameters:
  • name (str) – Name of the queue that messages should be sent to.
  • args (str) – Path to the file that messages should be read from.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in additon to parent class’s):
args (str): Path to the file that messages should be read from. fd (file-like): File descriptor for the input file while it is open. lock (threading.Lock): Lock to be used when accessing file.
close_file()[source]

Close the file.

run()[source]

Run the driver. The file is opened and then data is read from the file and sent to the message queue until eof is encountered or the file is closed.

terminate()[source]

Terminate the driver. The file is closed as necessary.

cis_interface.drivers.FileOutputDriver module

class cis_interface.drivers.FileOutputDriver.FileOutputDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.IODriver.IODriver

Class to handle output of received messages to a file.

Parameters:
  • name (str) – Name of the output queue to receive messages from.
  • args (str) – Path to the file that messages should be written to.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in addition to parent class’s):
args (str): Path to the file that messages should be written to. fd (file-like): File descriptor for the target file if open. lock (threading.Lock): Lock to be used when accessing file.
close_file()[source]

Close the file.

run()[source]

Run the driver. The driver will open the file and write receieved messages to the file as they are received until the file is closed.

terminate()[source]

Terminate the driver, closeing the file as necessary.

cis_interface.drivers.GCCModelDriver module

class cis_interface.drivers.GCCModelDriver.GCCModelDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.ModelDriver.ModelDriver

Class from running gcc compiled driveres.

Parameters:
  • name (str) – Driver name.
  • args (str or list) – Argument(s) for running the model on the command line. If the first element ends with ‘.c’, the driver attempts to compile the code with the necessary interface include directories. Additional arguments that start with ‘-I’ are included in the compile command. Others are assumed to be runtime arguments.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in additon to parent class’s):
compiled (bool): True if the compilation was succesful. False otherwise.
run()[source]

Run the compiled executable if it exists.

cis_interface.drivers.IODriver module

class cis_interface.drivers.IODriver.IODriver(name, suffix='', **kwargs)[source]

Bases: cis_interface.drivers.Driver.Driver

Base driver for any driver that requires access to a message queue.

Parameters:
  • name (str) – The name of the message queue that the driver should connect to.
  • suffix (str, optional) – Suffix added to name to create the environment variable where the message queue key is stored. Defaults to ‘’.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in addition to parent class’s):
state (str): Description of the last operation performed by the driver. numSent (int): The number of messages sent to the queue. numReceived (int): The number of messages received from the queue. env (dict): Environment variables. mq (sysv_ipc.MessageQueue): Message queue.
close_queue()[source]

Close the queue.

graceful_stop(timeout=0, **kwargs)[source]

Stop the IODriver, first draining the message queue.

Parameters:
  • timeout (float, optional) – Max time that should be waited. Defaults to 0 and is set to attribute timeout.
  • **kwargs – Additional keyword arguments are passed to the parent class’s graceful_stop method.
ipc_recv()[source]

Receive a message smaller than maxMsgSize.

Returns:The received message.
Return type:str
ipc_recv_nolimit()[source]

Receive a message larger than maxMsgSize in multiple parts.

Returns:The complete received message.
Return type:str
ipc_send(data)[source]

Send a message smaller than maxMsgSize.

Parameters:str – The message to be sent.
ipc_send_nolimit(data)[source]

Send a message larger than maxMsgSize in multiple parts.

Parameters:str – The message to be sent.
n_ipc_msg

int – The number of messages in the queue.

on_model_exit()[source]

Actions to perform when the associated model driver is finished.

printStatus(beg_msg='', end_msg='')[source]

Print information on the status of the IODriver.

Parameters:
  • beg_msg (str, optional) – Additional message to print at beginning.
  • end_msg (str, optional) – Additional message to print at end.
recv_wait(timeout=0)[source]

Receive a message smaller than maxMsgSize. Unlike ipc_recv, recv_wait will wait until there is a message to receive or the queue is closed.

Parameters:timeout (float, optional) – Max time that should be waited. Defaults to 0 and is set to attribute timeout.
Returns:The received message.
Return type:str
recv_wait_nolimit(timeout=0)[source]

Receive a message larger than maxMsgSize. Unlike ipc_recv, recv_wait will wait until there is a message to receive or the queue is closed.

Parameters:timeout (float, optional) – Max time that should be waited. Defaults to 0 and is infinite.
Returns:The received message.
Return type:str
terminate()[source]

Stop the IODriver, removing the queue.

cis_interface.drivers.MatInputDriver module

class cis_interface.drivers.MatInputDriver.MatInputDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.FileInputDriver.FileInputDriver

Class that sends pickled dictionaries of matricies read from a .mat file.

Parameters:
  • name (str) – Name of the queue that messages should be sent to.
  • args (str) – Path to the .mat file that messages should be read from.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in addition to parent class’s):
get()[source]

Returned pickled data read from the .mat file.

Returns:Pickled .mat dictionary of read variables.
Return type:data (str)
run()[source]

Run the driver. The .mat file is opened and contents are read and then sent to the message queue until EOF is encountered or the file is closed.

cis_interface.drivers.MatOutputDriver module

class cis_interface.drivers.MatOutputDriver.MatOutputDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.FileOutputDriver.FileOutputDriver

Class to handle output to .mat Matlab files.

Parameters:
  • name (str) – Name of the output queue to receive messages from.
  • args (str) – Path to the file that messages should be written to.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in addition to parent class’s):
put(data)[source]

Write received data to file. The data is first unpickled and then written in .mat format.

Parameters:data (str) – Pickled dictionary of objects to write to the .mat file.
run()[source]

Run the driver. The driver will open the file and write receieved messages to the file as they are received until the file is closed.

cis_interface.drivers.MatlabModelDriver module

class cis_interface.drivers.MatlabModelDriver.MatlabModelDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.ModelDriver.ModelDriver

Base class for running Matlab models.

Parameters:
  • name (str) – Driver name.
  • args (str or list) – Argument(s) for running the model in matlab. Generally, this should be the full path to a Matlab script.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
started_matlab

bool – True if the driver had to start a new matlab engine. False otherwise.

screen_session

str – Screen session that Matlab was started in.

mlengine

object – Matlab engine used to run script.

mlsession

str – Name of the Matlab session that was started.

cleanup()[source]

Close the Matlab session and engine.

on_exit()[source]

Cleanup Matlab session and engine on exit.

run()[source]

Run the matlab script in the matlab engine.

terminate()[source]

Terminate the driver, including the matlab engine.

cis_interface.drivers.MatlabModelDriver.start_matlab()[source]

Start a Matlab shared engine session inside a detached screen session.

Returns:Name of the screen session running matlab.
Return type:str
cis_interface.drivers.MatlabModelDriver.stop_matlab(screen_session, matlab_engine, matlab_session)[source]

Stop a Matlab shared engine session running inside a detached screen session.

Parameters:
  • screen_session (str) – Name of the screen session that the shared Matlab session was started in.
  • matlab_engine (MatlabEngine) – Matlab engine that should be stopped.
  • matlab_session (str) – Name of Matlab session that the Matlab engine is connected to.

cis_interface.drivers.ModelDriver module

class cis_interface.drivers.ModelDriver.ModelDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.Driver.Driver

Base class form Model drivers.

Parameters:
  • name (str) – Driver name.
  • args (str or list) – Argument(s) for running the model on the command line.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in additon to parent class’s):
args (list): Argument(s) for running the model on the command line. process (subprocess.Popen): Process used to run the model. env (dict): Dictionary of environment variables.
run()[source]

Run the model on a new process, receiving output from.

terminate()[source]

Terminate the process running the model.

cis_interface.drivers.ModelDriver.preexec()[source]

cis_interface.drivers.PythonModelDriver module

class cis_interface.drivers.PythonModelDriver.PythonModelDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.ModelDriver.ModelDriver

Class for running Python models.

Parameters:
  • name (str) – Driver name.
  • args (str or list) – Argument(s) for running the model on the command after the call to python.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in additon to parent class’s):

cis_interface.drivers.RMQClientDriver module

class cis_interface.drivers.RMQClientDriver.RMQClientDriver(name, args=None, **kwargs)[source]

Bases: cis_interface.drivers.RMQDriver.RMQDriver, cis_interface.drivers.RPCDriver.RPCDriver

Class for handling client side RPC type RabbitMQ communication.

Parameters:
  • name (str) – The name of the local IPC message queues that the driver should use.
  • args (str, optional) – The name of the server RabbitMQ message queue that requests should be sent to. Defaults to name + ‘_SERVER’ if not set.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
request_queue

str – The name of RabbitMQ message queue that requests will be sent to. (See args above).

response

str – Response to the most recent request.

corr_id

str – Correlation id for the most recent request.

on_model_exit()[source]

Stop when the model exits.

on_response(ch, method, props, body)[source]

Actions to perform when a reponse is received from the server.

publish_to_server(message, properties=None)[source]

Publish a message to the server queue.

schedule_next_message()[source]

Wait for next message.

schedule_next_response()[source]

Wait for next response.

start_communication(no_ack=False)[source]

Start publishing messages to the queue.

start_publishing()[source]

Begin moving messages from IPC queue to RMQ queue.

stop_communication()[source]

Stop consuming messages from the queue.

cis_interface.drivers.RMQDriver module

class cis_interface.drivers.RMQDriver.RMQDriver(name, queue='', routing_key=None, **kwargs)[source]

Bases: cis_interface.drivers.Driver.Driver

Class for handling basic RabbitMQ communications.

Parameters:
  • name (str) – The name of the driver.
  • queue (str, optional) – Name of the queue that messages will be received from. If and empty string, the queue is exclusive to this connection. Defaults to ‘’.
  • routing_key (str, optional) – Routing key that should be used when the queue is bound. If None, the queue name is used. Defaults to None.
  • user (str, optional) – RabbitMQ server username. Defaults to config option ‘user’ in section ‘rmq’.
  • host (str, optional) – RabbitMQ server host. Defaults to config option ‘host’ in section ‘rmq’ if it exists and the output of socket.gethostname() if it does not.
  • vhost (str, optional) – RabbitMQ server virtual host. Defaults to config option ‘vhost’ in section ‘rmq’.
  • passwd (str, optional) – RabbitMQ server password. Defaults to config option ‘password’ in section ‘rmq’.
  • exchange (str, optional) – RabbitMQ exchange. Defaults to ‘namespace’ attribute which is set from the config option ‘namespace’ in the section ‘rmq’.
  • exclusive (bool, optional) – If True, the queue that is created can only be used by this driver. Defaults to False. If a queue name is not provided, it is assumed exclusive.
user

str – RabbitMQ server username.

passwd

str – RabbitMQ server password.

host

str – RabbitMQ server host.

vhost

str – RabbitMQ server virtual host.

exchange

str – RabbitMQ exchange name.

connection

pika.Connection – RabbitMQ connection.

channel

pika.Channel – RabbitMQ channel.

queue

str – Name of the queue that messages will be received from. If an empty string, the queue is exclusive to this connection.

routing_key

str – Routing key that should be used when the queue is bound. If None, the queue name is used.

times_connected

int – Number of times the connection has been established/re-established.

connect()[source]

Establish the connection.

connection_parameters

pika.connection.ConnectionParameters – Connection parameters.

creds

pika.credentials.PlainCredentials – Server credentials.

get_message_stats()[source]

Return message stats from the server.

is_open

bool – True if connection ready for messages, False otherwise.

is_stable

bool – True if the connection ready for messages and not about to close. False otherwise.

n_rmq_msg

int – Number of messages in the queue.

on_bindok(unused_frame)[source]

Actions to perform once the queue is succesfully bound. Start consuming messages.

on_channel_closed(channel, reply_code, reply_text)[source]

Actions to perform when the channel is closed. Close the connection.

on_channel_open(channel)[source]

Actions to perform after a channel is opened. Add the channel close callback and setup the exchange.

on_connection_closed(connection, reply_code, reply_text)[source]

Actions that must be taken when the connection is closed. Set the channel to None. If the connection is meant to be closing, stop the IO loop. Otherwise, wait 5 seconds and try to reconnect.

on_connection_open(unused_connection)[source]

Actions that must be taken when the connection is opened. Add the close connection callback and open the RabbitMQ channel.

on_connection_open_error(unused_connection)[source]

Actions that must be taken when the connection fails to open.

on_exchange_declareok(unused_frame)[source]

Actions to perform once an exchange is succesfully declared. Set up the queue.

on_nmsg_request(method_frame)[source]

Actions to perform once the queue is declared for message count.

on_queue_declareok(method_frame)[source]

Actions to perform once the queue is succesfully declared. Bind the queue.

open_channel()[source]

Open a RabbitMQ channel.

printStatus()[source]

Print the driver status.

purge_queue()[source]

Remove all messages from the associated queue.

reconnect()[source]

Try to re-establish a connection and resume a new IO loop.

rmq_send(data)[source]

Send a message smaller than maxMsgSize to the RMQ queue.

Parameters:data (str) – The message to be sent.
Returns:True if the message was sent succesfully. False otherwise.
Return type:bool
rmq_send_nolimit(data)[source]

Send a message smaller than maxMsgSize to the RMQ queue.

Parameters:data (str) – The message to be sent.
Returns:True if the message was sent succesfully. False otherwise.
Return type:bool
run()[source]

Run the driver. Connect to the connection and begin the IO loop.

setup_exchange(exchange_name)[source]

Setup the exchange.

setup_queue(queue_name)[source]

Set up the message queue.

start()[source]

Start the driver. Waiting for connection.

start_communication(**kwargs)[source]

Start sending/receiving messages.

stop_communication(remove_queue=True, **kwargs)[source]

Stop sending/receiving messages.

terminate()[source]

Terminate the driver by closing the RabbitMQ connection.

cis_interface.drivers.RMQInputDriver module

Module for receiving input from a RabbitMQ server.

class cis_interface.drivers.RMQInputDriver.RMQInputDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.RMQDriver.RMQDriver, cis_interface.drivers.IODriver.IODriver

Driver for receiving input from a RabbitMQ server.

Parameters:
  • name (str) – The name of the local message queue that the driver should connect to.
  • args (str) – The name of the RabbitMQ message queue that the driver should connect to.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in addition to parent class’s):
on_message(ch, method, props, body)[source]

Action to perform when a message is received. Send it to the local queue and acknowledge the message.

start_communication()[source]

Begin consuming messages and add the callback for cancelling consumption.

cis_interface.drivers.RMQOutputDriver module

Module for sending output to a RabbitMQ server.

class cis_interface.drivers.RMQOutputDriver.RMQOutputDriver(name, args, **kwargs)[source]

Bases: cis_interface.drivers.RMQDriver.RMQDriver, cis_interface.drivers.IODriver.IODriver

Driver for sending output to a RabbitMQ server.

Parameters:
  • name (str) – The name of the local message queue that the driver should connect to.
  • args (str) – The name of the RabbitMQ message queue that the driver connect to.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in addition to parent class’s):
publish_message()[source]

Continue receiving messages from the local queue and passing them to the RabbitMQ server until the queue is closed.

start_communication()[source]

Start publishing messages from the local queue.

stop_communication(**kwargs)[source]

Stop sending/receiving messages. Only RMQInputDriver should explicitly delete the queue.

cis_interface.drivers.RMQServerDriver module

class cis_interface.drivers.RMQServerDriver.RMQServerDriver(name, args=None, **kwargs)[source]

Bases: cis_interface.drivers.RMQDriver.RMQDriver, cis_interface.drivers.RPCDriver.RPCDriver

Class for handling server side RPC type RabbitMQ communication.

Parameters:
  • name (str) – The name of the local IPC message queues that the driver should use.
  • args (str, optional) – The name of the RabbitMQ message queue that the driver should connect to. Defaults to name + ‘_SERVER’ if not set.
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in addition to the parent class’s):
clients (set): The unique clients subscribed to this server.
n_clients

int – The number of clients that are submitting requests to the server.

on_message(ch, method, props, body)[source]

Actions to perform when a message is received.

on_queue_declareok(method_frame)[source]

Actions to perform once the queue is succesfully declared.

start_communication(no_ack=False)[source]

Start consuming messages from the queue.

cis_interface.drivers.RPCDriver module

class cis_interface.drivers.RPCDriver.RPCDriver(name, args=None, **kwargs)[source]

Bases: cis_interface.drivers.Driver.Driver

Base class for any driver that requires to access to input & output queues for RPC type functionality.

Parameters:
  • name (str) – The name of the message queue set that the driver should connect to. (name + “_IN” and name + “_OUT”)
  • **kwargs – Additional keyword arguments are passed to parent class’s __init__ method.
Attributes (in addition to parent class’s):
iipc (cis_interface.drivers.IODriver): Driver for the input
message queue.
oipc (cis_interface.drivers.IODriver): Driver for the output
message ueue.
env

dict – Environment variables.

graceful_stop()[source]

Allow the IPC queues to terminate gracefully.

ipc_recv(use_output=False)[source]

Receive message smaller than maxMsgSize from the input queue.

Parameters:use_output (bool, optional) – If True, the message is received from the output queue instead of the input one.
Returns:The received message.
Return type:str
ipc_recv_nolimit(use_output=False)[source]

Receive message larger than maxMsgSize from the output queue.

Parameters:use_output (bool, optional) – If True, the message is received from the output queue instead of the input one.
Returns:The received message.
Return type:str
ipc_send(data, use_input=False)[source]

Send message smaller than maxMsgSize to the output queue.

Parameters:
  • data (str) – Message to be sent.
  • use_input (bool, optional) – If True, the message is sent to the input queue instead of the output one.
ipc_send_nolimit(data, use_input=False)[source]

Send message larger than maxMsgSize to the input queue.

Parameters:
  • data (str) – Message to be sent.
  • use_input (bool, optional) – If True, the message is sent to the input queue instead of the output one.
n_msg_in

int – The number of messages in the input queue.

n_msg_out

int – The number of messages in the output queue.

on_model_exit()[source]

Actions to perform when the associated model driver is finished.

printStatus()[source]

Print information on the status of the driver.

recv_wait(use_output=False, timeout=0.0)[source]

Receive a message smaller than maxMsgSize. This method will wait until there is a message in the queue to return or the queue is closed.

Parameters:
  • use_output (bool, optional) – If True, the message is received from the output queue instead of the input one.
  • timeout (float, optional) – Max time that should be waited. Defaults to 0 and is infinite.
Returns:

The received message.

Return type:

str

recv_wait_nolimit(use_output=False, timeout=0.0)[source]

Receive a message larger than maxMsgSize. This method will wait until there is a message in the queue to return or the queue is closed.

Parameters:
  • use_output (bool, optional) – If True, the message is received from the output queue instead of the input one.
  • timeout (float, optional) – Max time that should be waited. Defaults to 0 and is infinite.
Returns:

The received message.

Return type:

str

run()[source]

Run the input/output queue drivers.

terminate()[source]

Terminate input/output queue drivers.

Module contents

IO and Model drivers.