The launcher.py module#

Summary#

ServerThread

Provides server thread properties.

check_ports

Check the state of ports in a port range.

port_in_use

Determine if a port is in use at a given host.

get_virtualenv_path

Get the virtual environment path.

launch_grpc

Launch the pre service locally in gRPC mode.

launch_remote_dynapre

Start DYNA PRE remotely using the product instance management API.

launch_dynapre

Start the pre service locally.

Description#

Module for launching the pre service locally.

Module detail#

launcher.check_ports(port_range, ip='localhost')#

Check the state of ports in a port range.

Parameters:
port_range
ipstr, optional

IP address. The default is "localhost", in which case ``”127.0.0.1”``is used.

launcher.port_in_use(port, host=LOCALHOST)#

Determine if a port is in use at a given host.

Parameters:
portint

Port.

host
Host. The default is LOCALHOST, in which case "127.0.0.1"

is used.

Returns:
True when a port is in use at the given host, False otherwise.

Notes

The port must “bind” the address. Just checking if a socket can be created is insufficient because it is possible to run into permission errors like this one:

“An attempt was made to access a socket in a way forbidden by its access permissions.”

launcher.get_virtualenv_path()#

Get the virtual environment path.

launcher.launch_grpc(port=DYNAPRE_DEFAULT_PORT, ip=LOCALHOST, server_path='') tuple#

Launch the pre service locally in gRPC mode.

Parameters:
portint, optional

Port to launch the pre service on. The default is DYNAPRE_DEFAULT_PORT. The final port is the first port available after (or including) this port.

ipstr, optional

IP address. The default is LOCALHOST, in which case "127.0.0.1" is used.

server_pathstr, optional

Path to the pre service. The default is None.

Returns:
int

Port number that the gRPC instance started on.

launcher.launch_remote_dynapre(version=None, cleanup_on_exit=True) ansys.dyna.core.pre.dynasolution.DynaSolution#

Start DYNA PRE remotely using the product instance management API.

When calling this method, you need to ensure that you are in an environment where PyPIM is configured. This can be verified with pypim.is_configured.

Parameters:
versionstr, optional

The DYNA version to run, in the 3 digits format, such as “212”.

If unspecified, the version will be chosen by the server.

cleanup_on_exitbool, optional

Exit DYNA when python exits or the dyna Python instance is garbage collected.

If unspecified, it will be cleaned up.

Returns:
ansys.dyna.core.pre.DynaSolution

An instance of DynaSolution.

launcher.launch_dynapre(port=50051, ip='localhost') ansys.dyna.core.pre.dynasolution.DynaSolution#

Start the pre service locally.

Parameters:
portint, optional

Port to launch MAPDL gRPC on. The default is 50051.

ipbool, optional

IP address or host name of the PyDYNA instance to connect to. The default is "localhost", in which case "127.0.0.1" is used.

launcher.LOCALHOST = '127.0.0.1'#
launcher.DYNAPRE_DEFAULT_PORT = 50051#
launcher.SERVER_PRE_VERSION = 'v0.4.6'#
launcher.MAX_MESSAGE_LENGTH = 8388608#
launcher.server_path#