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.
- 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:
RuntimeError – If the instance is already in the stopped state.
RuntimeError – If the URLs exposed by the started instance do not match the expected ones defined in the launcher’s
LauncherProtocol.SERVER_SPEC
attribute.
- Return type:
- start()#
Start the product instance.
- Raises:
RuntimeError – If the instance is already in the started state.
RuntimeError – If the URLs exposed by the started instance do not match the expected ones defined in the launcher’s
LauncherProtocol.SERVER_SPEC
attribute.
- Return type:
- 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:
- 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: