libmuscle.manager.instance_registry module

exception libmuscle.manager.instance_registry.AlreadyRegistered[source]

Bases: RuntimeError

class libmuscle.manager.instance_registry.InstanceRegistry[source]

Bases: object

Keeps track of running instances.

The InstanceRegistry is a simple in-memory database that stores information about running instances of simulation components.

add(name: Reference, locations: List[str], ports: List[Port]) None[source]

Add an instance to the registry.

Parameters:
  • name – Name of the instance.

  • locations – Network locations where it can be reached.

  • ports – List of ports of this instance.

Raises:

ValueError – If an instance with this name has already been registered.

did_register(name: Reference) bool[source]

Check whether the instance has registered at some point.

This returns True iff the instance registered at some point before the function was called. If it was subsequently deregistered, this will still return True.

Parameters:

name – Name of the instance to check.

get_locations(name: Reference) List[str][source]

Retrieves the locations of a registered instance.

Parameters:

name – The name of the instance to get the location of.

Raises:

KeyError – If no instance with this name was registered.

get_ports(name: Reference) List[Port][source]

Retrieves the ports of a registered instance.

Parameters:

name – The name of the instance whose ports to retrieve.

Raises:

KeyError – If no instance with this name was registered.

remove(name: Reference) None[source]

Remove an instance from the registry.

Parameters:

name – Name of the instance to remove.

Raises:

KeyError – If the instance does not exist.

wait() None[source]

Waits until all instances are deregistered.

This function blocks, and returns after each instance has been registered and deregistered again, signally the end of the simulation run.