simbilod / meshwell

GMSH wrapper, with integrated photonics focus
https://simbilod.github.io/meshwell/
GNU General Public License v3.0
22 stars 3 forks source link

Fix using Meshwell in Ray #17

Open nikosavola opened 1 year ago

nikosavola commented 1 year ago

Meshwell meshing fails for me when running in Ray

    component.to_gmsh(
  File "/usr/local/home/nikosavola/dev/gdsfactory/gdsfactory/component.py", line 2548, in to_gmsh
    return xyz_mesh(padded_component, layer_stack, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/google/home/nikosavola/dev/gdsfactory/gdsfactory/simulation/gmsh/xyz_mesh.py", line 145, in xyz_mesh
    mesh_out = model.mesh(
               ^^^^^^^^^^^
  File "/usr/local/home/nikosavola/dev/meshwell/meshwell/model.py", line 289, in mesh
    gmsh.finalize()
  File "/usr/local/home/nikosavola/venv/gdsfactory/lib/python3.11/site-packages/gmsh.py", line 316, in finalize
    signal.signal(signal.SIGINT, oldsig)
  File "/usr/lib/python3.11/signal.py", line 56, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: signal only works in main thread of the main interpreter

The issue is documented in https://gitlab.onelab.info/gmsh/gmsh/-/issues/2399 and the solution is to use new initialization with gmsh.intialize(interruptible=False). This argument however is not in a release version of gmsh.

nikosavola commented 1 year ago

The local fix is easy enough that maybe this should be fixed after a new version of gmsh is released