Product instance#

Defines a wrapper for interacting with launched product instances.

class ansys.tools.local_product_launcher.product_instance.ProductInstance(*, launcher)#

Provides a wrapper for interacting with the launched product instance.

This class allows stopping and starting of the product instance. It also provides access to its server URLs/channels.

The ProductInstance class can be used as a context manager, stopping the instance when exiting the context.

property channels: dict[str, grpc.Channel]#

Channels to the gRPC servers of the product instance.

check(timeout=None)#

Check if all servers are responding to requests.

Parameters:

timeout (Optional[float], default: None) – Time in seconds to wait for the servers to respond. There is no guarantee that the check() method returns within this time. Instead, this parameter is used as a hint to the launcher implementation.

Return type:

bool

restart(stop_timeout=None)#

Stop and then start the product instance.

Parameters:

stop_timeout (Optional[float], default: None) – Time in seconds after which the instance is forcefully stopped. Not all launch methods implement this parameter. If the parameter is not implemented, it is ignored.

Raises:
Return type:

None

start()#

Start the product instance.

Raises:
Return type:

None

stop(*, timeout=None)#

Stop the product instance.

Parameters:

timeout (Optional[float], default: None) – Time in seconds after which the instance is forcefully stopped. Not all launch methods implement this parameter. If the parameter is not implemented, it is ignored.

Raises:

RuntimeError – If the instance is already in the stopped state.

Return type:

None

property stopped: bool#

Flag indicating if the product instance is currently stopped.

property urls: dict[str, str]#

URL and port for the servers of the product instance.

wait(timeout)#

Wait for all servers to respond.

This method repeatedly checks if the servers are running, returning as soon as they are all ready.

Parameters:

timeout (float) – Wait time in seconds before raising an exception.

Raises:

RuntimeError – If the server still has not responded after timeout seconds.

Return type:

None