Fix GIL issue (see previous commit for details)

This commit is contained in:
Matthias Hochsteger 2024-06-21 11:45:16 +02:00
parent 163135981e
commit af5e003790
2 changed files with 12 additions and 17 deletions

View File

@ -1234,15 +1234,12 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
{ {
MeshingParameters mp; MeshingParameters mp;
if(pars) mp = *pars; if(pars) mp = *pars;
{
py::gil_scoped_acquire acquire;
CreateMPfromKwargs(mp, kwargs); CreateMPfromKwargs(mp, kwargs);
} py::gil_scoped_release gil_release;
MeshVolume (mp, self); MeshVolume (mp, self);
OptimizeVolume (mp, self); OptimizeVolume (mp, self);
}, py::arg("mp")=nullptr, }, py::arg("mp")=nullptr,
meshingparameter_description.c_str(), meshingparameter_description.c_str())
py::call_guard<py::gil_scoped_release>())
.def ("OptimizeVolumeMesh", [](Mesh & self, MeshingParameters* pars) .def ("OptimizeVolumeMesh", [](Mesh & self, MeshingParameters* pars)
{ {

View File

@ -188,7 +188,6 @@ NGCORE_API_EXPORT void ExportSTL(py::module & m)
{ {
MeshingParameters mp; MeshingParameters mp;
STLParameters stlparam; STLParameters stlparam;
{ py::gil_scoped_acquire aq;
if(pars) if(pars)
{ {
auto mp_flags = pars->geometrySpecificParameters; auto mp_flags = pars->geometrySpecificParameters;
@ -198,7 +197,7 @@ NGCORE_API_EXPORT void ExportSTL(py::module & m)
} }
CreateSTLParametersFromKwargs(stlparam, kwargs); CreateSTLParametersFromKwargs(stlparam, kwargs);
CreateMPfromKwargs(mp, kwargs); // this will throw if any kwargs are not passed CreateMPfromKwargs(mp, kwargs); // this will throw if any kwargs are not passed
} py::gil_scoped_release gil_release;
if(!mesh) if(!mesh)
{ {
mesh = make_shared<Mesh>(); mesh = make_shared<Mesh>();
@ -215,7 +214,6 @@ NGCORE_API_EXPORT void ExportSTL(py::module & m)
return mesh; return mesh;
}, py::arg("mp") = nullptr, py::arg("mesh") = nullptr, }, py::arg("mp") = nullptr, py::arg("mesh") = nullptr,
py::call_guard<py::gil_scoped_release>(),
(meshingparameter_description + stlparameter_description).c_str()) (meshingparameter_description + stlparameter_description).c_str())
.def("Draw", FunctionPointer .def("Draw", FunctionPointer
([] (shared_ptr<STLGeometry> self) ([] (shared_ptr<STLGeometry> self)