ProductInstance#

class ansys.tools.common.launcher.product_instance.ProductInstance(*, launcher: ansys.tools.common.launcher.interface.LauncherProtocol[ansys.tools.common.launcher.interface.LAUNCHER_CONFIG_T])#

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 and gRPC channels.

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

Overview#

start

Start the product instance.

stop

Stop the product instance.

restart

Stop and then start the product instance.

check

Check if all servers are responding to requests.

wait

Wait for all servers to respond.

urls

Read-only mapping of server keys to their URLs.

stopped

Flag indicating if the product instance is currently stopped.

channels

Read-only mapping of server keys to gRPC channels.

__enter__

Enter the context manager defined by the product instance.

__exit__

Stop the product instance when exiting a context manager.

Import detail#

from ansys.tools.common.launcher.product_instance import ProductInstance

Property detail#

property ProductInstance.urls: Mapping[str, str]#

Read-only mapping of server keys to their URLs.

property ProductInstance.stopped: bool#

Flag indicating if the product instance is currently stopped.

property ProductInstance.channels: Mapping[str, grpc.Channel]#

Read-only mapping of server keys to gRPC channels.

Method detail#

ProductInstance.__enter__() ProductInstance#

Enter the context manager defined by the product instance.

ProductInstance.__exit__(*exc: Any) None#

Stop the product instance when exiting a context manager.

ProductInstance.start() None#

Start the product instance.

Raises#

ProductInstanceError

If the instance is already started or the URLs do not match the launcher’s SERVER_SPEC.

ProductInstance.stop(*, timeout: float | None = None) None#

Stop the product instance.

Parameters#

timeoutfloat, default: None

Time in seconds after which the instance is forcefully stopped. Not all launch methods implement this parameter.

Raises#

ProductInstanceError

If the instance is already stopped.

ProductInstance.restart(stop_timeout: float | None = None) None#

Stop and then start the product instance.

Parameters#

stop_timeoutfloat, default: None

Time in seconds after which the instance is forcefully stopped.

Raises#

ProductInstanceError

If the instance is already stopped or URL keys mismatch.

ProductInstance.check(timeout: float | None = None) bool#

Check if all servers are responding to requests.

Parameters#

timeoutfloat, 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.

ProductInstance.wait(timeout: float) None#

Wait for all servers to respond.

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

Parameters#

timeoutfloat, default: None

Wait time in seconds before raising an exception.

Raises#

ProductInstanceError

If the server still has not responded after timeout seconds.