Skip to content

Commit

Permalink
fixing recovering MAPDL instance between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
germa89 committed Mar 20, 2024
1 parent 6737405 commit 68d9961
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ def requires_dependency(dependency: str):

pymapdl.RUNNING_TESTS = True

from ansys.mapdl.core.errors import MapdlExitedError, MapdlRuntimeError
from ansys.mapdl.core import Mapdl
from ansys.mapdl.core.errors import (
MapdlConnectionError,
MapdlExitedError,
MapdlRuntimeError,
)
from ansys.mapdl.core.examples import vmfiles
from ansys.mapdl.core.launcher import get_start_instance, launch_mapdl

Expand Down Expand Up @@ -376,18 +381,23 @@ def is_exited(mapdl):
if START_INSTANCE and is_exited(mapdl):
# Backing up the current local configuration
local_ = mapdl._local

# Relaunching MAPDL
mapdl_ = launch_mapdl(
port=mapdl._port,
override=True,
run_location=mapdl._path,
cleanup_on_exit=mapdl._cleanup,
)

# Cloning the new mapdl instance channel into the old one.
mapdl._channel = mapdl_._channel
mapdl._multi_connect(timeout=mapdl._timeout)
channel = mapdl._channel
try:
# to connect
mapdl = Mapdl(channel=channel)

except MapdlConnectionError:
# we cannot connect.
# Kill the instance
mapdl.exit()

# Relaunching MAPDL
mapdl_ = launch_mapdl(
port=mapdl._port,
override=True,
run_location=mapdl._path,
cleanup_on_exit=mapdl._cleanup,
)

# Restoring the local configuration
mapdl._local = local_
Expand Down

0 comments on commit 68d9961

Please sign in to comment.