Skip to content

gmsh report error "signal only works in main thread" #520

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

Open
YuanWenqing opened this issue Jan 30, 2022 · 4 comments
Open

gmsh report error "signal only works in main thread" #520

YuanWenqing opened this issue Jan 30, 2022 · 4 comments

Comments

@YuanWenqing
Copy link

I'm not familiar with gmsh and I want to use pygmsh to subdivide mesh in a grpc request. But it seems gmsh limits multi-threading support in default.

  ...
  File "gmshutil.py", line 22, in subdivide_obj
    mesh = geom.generate_mesh()
  File "python3.6/site-packages/pygmsh/common/geometry.py", line 54, in __exit__
    gmsh.finalize()
  File "python3.6/site-packages/gmsh.py", line 261, in finalize
    signal.signal(signal.SIGINT, oldsig)
  File "python3.6/signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread

I read http://gmsh.info/doc/texinfo/gmsh.html and tried solutions in #317

gmsh.option.setNumber('General.NumThreads', 32)
# OR
gmsh.option.setNumber('Mesh.Algorithm3D', 32)

But problem's not solved.

Could somebody help?

@thisistheplace
Copy link

thisistheplace commented Sep 4, 2022

Upvoted. I have the same error calling gmsh from FastAPI endpoints. I'm guessing the server is using the main thread and the error comes about when gmsh is executed in a worker thread. Will let you know if I get anywhere :)

@JTHesse
Copy link

JTHesse commented Nov 21, 2022

@thisistheplace were you able to fix the error?

@thisistheplace
Copy link

Hi, I ended up running gmsh in a separate process to the server and using a messaging queue.

E.g. gmsh gets called in this line:

https://github.com/thisistheplace/joint_model/blob/ab3aa2985908846698d6358c3a51dc56dbee738a/src/app/server/worker/worker.py#L84

@JTHesse
Copy link

JTHesse commented Nov 21, 2022

Thanks for the response. I will try that!

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

3 participants