Skip to content

Mesh object not updating fast enough (Race condition) #1447

Closed
@germa89

Description

@germa89

Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment
  • I have a fully updated virtual environment (i.e. pip install --upgrade --upgrade-strategy eager ansys-mapdl-core)

Description of the bug

Problem

I have seen this test failing quite a lot:

=================================== FAILURES ===================================
____________________________ test_empty_mesh[False] ____________________________

mapdl = <ansys.mapdl.core.mapdl_grpc.MapdlGrpc object at 0x7f59e7ded400>
cleared = None

    def test_empty_mesh(mapdl, cleared):
        assert mapdl.mesh.n_node == 0
        assert mapdl.mesh.n_elem == 0
        assert mapdl.mesh.nnum_all.size == 0
        assert mapdl.mesh.enum_all.size == 0
        assert mapdl.mesh.nnum.size == 0
        assert mapdl.mesh.enum.size == 0
        assert mapdl.mesh.nodes.size == 0
        # assert mapdl.mesh.node_angles.size == 0 Not implemented
    
        # elem is a list
        assert len(mapdl.mesh.elem) == 0
    
        # Using size because it should be empty arrays
        assert mapdl.mesh.ekey.size == 0
        assert mapdl.mesh.et_id.size == 0
        assert mapdl.mesh.tshape.size == 0
        assert mapdl.mesh.material_type.size == 0
        assert mapdl.mesh.etype.size == 0
        assert mapdl.mesh.section.size == 0
        assert mapdl.mesh.element_coord_system.size == 0
        assert mapdl.mesh.elem_real_constant.size == 0
        assert mapdl.mesh.ekey.size == 0
    
        # should be empty dicts
        assert not mapdl.mesh.key_option
        assert not mapdl.mesh.tshape_key
        assert not mapdl.mesh.element_components
        assert not mapdl.mesh.node_components
    
        # bools
>       assert not mapdl.mesh._has_elements

tests/test_mesh_grpc.py:90: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = ANSYS Mesh
  Number of Nodes:              0
  Number of Elements:           0
  Number of Element Types:      0
  Number of Node Components:    0
  Number of Element Components: 0


    @property
    def _has_elements(self):
        """Returns True when geometry has elements"""
>       return self._elem.size != 0
E       AttributeError: 'NoneType' object has no attribute 'size'

/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/ansys/mapdl/core/mesh_grpc.py:89: AttributeError

Run: https://github.com/pyansys/pymapdl/runs/8184714817?check_suite_focus=true

Call to self._elem sometimes return None, I presume that it is because of a race conditions. self._elem is updated in a thread, and although, we wait for it to finish (join), it might not finish the thread or write the attribute soon enough.

Steps To Reproduce

It happens sometimes, not always.

Check:
https://github.com/pyansys/pymapdl/runs/8184714817?check_suite_focus=true

Which Operating System are you using?

No response

Which Python version are you using?

No response

PyMAPDL Report

NA

Installed packages

NA

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions