ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
419 stars 118 forks source link

gRPC send_command Stability #1376

Open akaszynski opened 1 year ago

akaszynski commented 1 year ago

Still seeing rare but reoccuring segfaults when sending commands. I'm willing on betting that this has to do with /OUT that we're firing off regardless of if the command is muted or not.

Note: Only the server instance is dying.

/usr/ansys_inc/v222/ansys/bin/ansysdis222: line 77: 260769 Segmentation fault      (core dumped) /usr/ansys_inc/v222/ansys/bin/linx64/ansys.e -grpc
______________________ test_plot_nodal_plastic_component_strain[False] _______________________

mapdl = <ansys.mapdl.core.mapdl_grpc.MapdlGrpc object at 0x7fa4ebaf0a60>, plastic_solve = None

    def test_plot_nodal_plastic_component_strain(mapdl, plastic_solve):
>       assert mapdl.post_processing.plot_nodal_plastic_component_strain("x") is None

tests/test_post.py:955: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/ansys/mapdl/core/post.py:2518: in plot_nodal_plastic_component_strain
    return self._plot_point_scalars(
src/ansys/mapdl/core/post.py:539: in _plot_point_scalars
    surf = self._mapdl.mesh._surf
../../python/py38/lib/python3.8/site-packages/ansys/mapdl/reader/mesh.py:125: in _surf
    self._surf_cache = self._grid.extract_surface()
src/ansys/mapdl/core/mesh_grpc.py:476: in _grid
    self._update_cache()
src/ansys/mapdl/core/mesh_grpc.py:106: in _update_cache
    self._mapdl.cmsel("S", TMP_NODE_CM, "NODE", mute=True)
src/ansys/mapdl/core/_commands/database/components.py:421: in cmsel
    return self.run(command, **kwargs)
src/ansys/mapdl/core/mapdl.py:2687: in run
    text = self._run(command, verbose=verbose, mute=mute)
src/ansys/mapdl/core/mapdl_grpc.py:747: in _run
    response = self._send_command(cmd, mute=mute)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<ansys.mapdl.core.mapdl_grpc.MapdlGrpc object at 0x7fa4ebaf0a60>, 'CMSEL,S,__NODE__,NO
DE')                                                                                         
kwargs = {'mute': True}, old_handler = <function handler at 0x7fa5037a0790>
class_name = 'MapdlGrpc'
mapdl = <ansys.mapdl.core.mapdl_grpc.MapdlGrpc object at 0x7fa4ebaf0a60>

    @wraps(func)
    def wrapper(*args, **kwargs):
        """Capture gRPC exceptions and KeyboardInterrupt"""

        # capture KeyboardInterrupt
        old_handler = None
        if threading.current_thread().__class__.__name__ == "_MainThread":
            if threading.current_thread().is_alive():
                old_handler = signal.signal(signal.SIGINT, handler)

        # Capture gRPC exceptions
        try:
            out = func(*args, **kwargs)
        except (_InactiveRpcError, _MultiThreadedRendezvous) as error:
            # can't use isinstance here due to circular imports
            try:
                class_name = args[0].__class__.__name__
            except:
                class_name = ""

            if class_name == "MapdlGrpc":
                mapdl = args[0]
            elif hasattr(args[0], "_mapdl"):
                mapdl = args[0]._mapdl

            # Must close unfinished processes
            mapdl._close_process()
>           raise MapdlExitedError("MAPDL server connection terminated") from None
E           ansys.mapdl.core.errors.MapdlExitedError: MAPDL server connection terminated

src/ansys/mapdl/core/errors.py:138: MapdlExitedError
akaszynski commented 1 year ago

Related failure:

    def test_plot_nodal_stress_intensity(mapdl, static_solve):
>       assert mapdl.post_processing.plot_nodal_stress_intensity() is None

tests/test_post.py:777: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/ansys/mapdl/core/post.py:1694: in plot_nodal_stress_intensity
    return self._plot_point_scalars(
src/ansys/mapdl/core/post.py:539: in _plot_point_scalars
    surf = self._mapdl.mesh._surf
../../python/py38/lib/python3.8/site-packages/ansys/mapdl/reader/mesh.py:125: in _surf
    self._surf_cache = self._grid.extract_surface()
src/ansys/mapdl/core/mesh_grpc.py:476: in _grid
    self._update_cache()
src/ansys/mapdl/core/mesh_grpc.py:106: in _update_cache
    self._mapdl.cmsel("S", TMP_NODE_CM, "NODE", mute=True)
src/ansys/mapdl/core/_commands/database/components.py:421: in cmsel
    return self.run(command, **kwargs)
src/ansys/mapdl/core/mapdl.py:2691: in run
    text = self._run(command, verbose=verbose, mute=mute)
src/ansys/mapdl/core/mapdl_grpc.py:747: in _run
    response = self._send_command(cmd, mute=mute)