Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyMAPDL connect to existing instance instead of creating a new one #1113

Closed
germa89 opened this issue May 10, 2022 · 12 comments
Closed

PyMAPDL connect to existing instance instead of creating a new one #1113

germa89 opened this issue May 10, 2022 · 12 comments
Assignees
Milestone

Comments

@germa89
Copy link
Collaborator

germa89 commented May 10, 2022

=== From internal feedback DK ===

If you have a PyMAPDL session running:

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(run_location="C:\temp\temp1")

and run another session:

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(run_location="C:\temp\temp2")

the later will connect into the former, which is not desirable.

@germa89 germa89 added the BUG label May 10, 2022
@germa89
Copy link
Collaborator Author

germa89 commented May 10, 2022

I need to have a look at this and see the implications. I'm creating this issue to raise visibility.

@germa89 germa89 changed the title PyMAPDL interaction PyMAPDL connect to existing instance instead of creating a new one May 10, 2022
@germa89 germa89 self-assigned this Jul 6, 2022
@germa89 germa89 added this to the v0.62.2 milestone Jul 6, 2022
@NFougeron
Copy link

Hi, I think I have this issue. It seems that when I start an analysis in one instance of APDL and want to work on a second analysis in the meantime both crash and I have some error message saying that I can't use some functions (from the second analysis) in the /SOLU menu (the one where is running the first analysis).

Do you have any idea on how to bypass this issue?

Thanks

@germa89
Copy link
Collaborator Author

germa89 commented Nov 18, 2022

Hi @NFougeron

Can you try specifying the ports for each instance??

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(port=50052, run_location="C:\temp\temp1")
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(port=50053, run_location="C:\temp\temp2")

@NFougeron
Copy link

NFougeron commented Nov 21, 2022 via email

@germa89
Copy link
Collaborator Author

germa89 commented Nov 21, 2022

We should probably consider implementing a logic that checks if an MAPDL instance is running already at the given port. If start_instance is equal to True, we should launch another instance in another port.

This might require some rewriting on the launcher module which might be difficult. Also we will need to list the instances (e.g. posix with ps aux).

@SerinaAnsys
Copy link

@germa89
Kind of stupid question, in windows system, how to know which port the 'mapdl' is using? And what should be a valid port number? Is it just a random number?

@germa89
Copy link
Collaborator Author

germa89 commented Jul 7, 2023

@germa89
Kind of stupid question, in windows system, how to know which port the 'mapdl' is using? And what should be a valid port number? Is it just a random number?

Hi @SerinaAnsys

By default the port is 50052. If the instance is already launched you can check mapdl.port in any OS.

>>> from ansys.mapdl.core import launch_mapdl
>>> mapdl = launch_mapdl()
>>> mapdl.port
50052 

Ideally a number above 50052. I tend to use any number between 50060-5080.

@SerinaAnsys
Copy link

@germa89


AttributeError Traceback (most recent call last)
Cell In[10], line 1
----> 1 mapdl.port

AttributeError: 'MapdlGrpc' object has no attribute 'port'

It seems doesn't work. Do you know why?

@SerinaAnsys
Copy link

Are we able to do that now? Suppose the mapdl is already exited, how can I check that and load a new one? Is there a command?

I tried to check ''mapdl' in locals()' and I see it's there.
However, I tried to type 'mapdl', it says, 'MAPDL exited'.

We should probably consider implementing a logic that checks if an MAPDL instance is running already at the given port. If start_instance is equal to True, we should launch another instance in another port.

@germa89
Copy link
Collaborator Author

germa89 commented Jul 10, 2023

Sorry... I meant mapdl._port.

@germa89
Copy link
Collaborator Author

germa89 commented Jul 10, 2023

You can know if the session exited by doing:

>>> mapdl._exited
True # if exited.

@germa89
Copy link
Collaborator Author

germa89 commented Feb 5, 2024

Most of the issues raised in this issue were fixed in:

@germa89 germa89 closed this as completed Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants