gmsh report error "signal only works in main thread"
YuanWenqing opened this issue · 4 comments
YuanWenqing commented
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 commented
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 commented
@thisistheplace were you able to fix the error?
thisistheplace commented
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:
JTHesse commented
Thanks for the response. I will try that!