Launch server from a Python script
Thelaunch_prime() method launches Ansys Prime Server.
This code returns an instance of the PyPrimeMesh Client class
connected to the launched server session:
Client class gets the model
parameter associated with the client instance:
Launch server from a Windows or Linux console and connect the client
You can launch Ansys Prime Server on Linux or Windows from a command prompt and then connect to the client as needed. This example starts the server in parallel mode on four nodes and specifies the IP address and port on Windows:- Launch the server from a command line:
- Connect to the server in Python using the
Clientclass:
NOTE
Only a single client session can be connected to an active Ansys Prime Server instance at any time.Disconnect from the server
TheClient.exit() method ends the connection with the server.
If the Client class launched the server, then this terminates the server process.
NOTE
If you use Intel(R) MPI Library, Version 2021.8, you may encounter the following error while exiting the client:
Run a Python script in batch on the server
You can run a Python script directly on the server from a Linux or Windows console. Here is a Windows code example for running a Python script directly from the command line:Recommendations for launching the server
When developing, you can use Python context to launch the server so that if an exception occurs during runtime the server closes cleanly. This prevents servers being spawned and left open blocking ports. This code example shows how to manage the server lifecycle using context to make development easier:Client.exit() method to close the server in this instance is not required.