iblrig.net.Auxiliaries

Inheritance diagram of Auxiliaries

class iblrig.net.Auxiliaries[source]
__init__(clients)[source]

Connect to and communicate with one or more remote rigs synchronously.

Parameters:

clients (dict[str, str]) – A map of name to URI.

static __new__(cls, *args, **kwargs)[source]
async cleanup(notify_services=False)[source]

Close connections and cleanup services.

This method closes all service communicators and cancels any pending callbacks.

Parameters:

notify_services (bool) – If true, send EXPCLEANUP message to remote devices before cleanup.

clear_message_queue()[source]

Clear queued messages.

Returns:

The number of aborted messages.

Return type:

int

close()[source]

Close communicators and wait for thread to terminate.

async create()[source]

Create remote services object.

Instantiates communicator objects which establish the UDP connections, wraps them in the Service class for bulk messaging, sets connected property to True and assigns some logging callbacks. This should be called from a daemon thread.

async listen()[source]

Listen for messages in queue and push to remote services.

Creates service communicators then awaits messages added to the queue. Once added, these are sent to the remote services and the collated responses are added to the log. Exits only after stop event is set. This should be called from a daemon thread.

push(message, *args, wait=False, **kwargs)[source]

Queue message for dispatch to remote services.

This method synchronously logs the request time and pushes the message to the queue for the asynchronous thread to handle.

Parameters:
  • message (iblutil.io.net.base.ExpMessage) – An experiment message to send to remote services.

  • args (any) – One or more optional variables to send.

  • wait (bool) – If True, this method is blocking and once all messages are received (or timed out) the collated responses are returned. Otherwise the request timestamp is returned for use as a log key when fetching the responses in a non-blocking manner.

  • kwargs – Optional keyword arguments to use in calling communicator methods (currently unused).

Returns:

An exception if failed to receive all responses in time, otherwise a map of service name and response if wait is true, or the request time if wait is false.

Return type:

Exception | dict | float

Raises:

RuntimeError – The async thread failed to return a response, most likely due to an error in the listen method.

Parameters:

message (ExpMessage)

connected = None

A thread event. Set by async thread once all services connected.

Type:

threading.Event

property is_connected: bool

True if successfully connected to services.

Type:

bool

property is_running: bool

True if listen is running on another thread.

Type:

bool

refresh_rate = 0.2

How long to wait between checking message queue.

Type:

float

response_received = None

A thread event. Notified each time the async thread receives all responses.

Type:

threading.Event

services = None

A map of remote services.

Type:

iblutil.io.net.app.Services

stop_event = None

A thread event. Once set, thread stops listening and clean up services.

Type:

threading.Event