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

mapdl.exit can be slow #3514

Open
germa89 opened this issue Oct 24, 2024 · 3 comments
Open

mapdl.exit can be slow #3514

germa89 opened this issue Oct 24, 2024 · 3 comments

Comments

@germa89
Copy link
Collaborator

germa89 commented Oct 24, 2024

I detected this while running on dev container. This method has become quite hacky. I should probably have a look at it eventually.

@germa89
Copy link
Collaborator Author

germa89 commented Oct 25, 2024

Things to consider: https://stackoverflow.com/questions/21053380/what-does-del-do-exactly

Having multiple references to MAPDL itself might be a performance penalty and might avoid killing MAPDL on time.

Stack Overflow
Here is my code:

from memory_profiler import profile

@Profile
def mess_with_memory():
huge_list = range(20000000)
del huge_list
print "why this kolaveri di?"
This is what the output ...

@germa89
Copy link
Collaborator Author

germa89 commented Oct 25, 2024

Removing:

        try:
            self.exit(force=True)
        except Exception as e:
            pass

        # Adding super call per:
        # https://docs.python.org/3/reference/datamodel.html#object.__del__
        try:
            super().__del__()
        except Exception as e:
            pass

to speed up the deletion from #3497.

@germa89
Copy link
Collaborator Author

germa89 commented Oct 25, 2024

More stuff to consider later:

@patch("ansys.mapdl.core.Mapdl.__init__", lambda *args, **kwargs: None)
def test_delete_mapdl_object():
    mapdl_b = pymapdl.Mapdl()
    mapdl_b._mapdl_on_hpc = True

    with patch("ansys.mapdl.core.mapdl_grpc.MapdlGrpc.kill_job") as mock_exit:
        del mapdl_b
        mock_exit.assert_called_once()

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

1 participant