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;
if(pars) mp = *pars;
{
py::gil_scoped_acquire acquire;
CreateMPfromKwargs(mp, kwargs);
}
CreateMPfromKwargs(mp, kwargs);
py::gil_scoped_release gil_release;
MeshVolume (mp, self);
OptimizeVolume (mp, self);
}, py::arg("mp")=nullptr,
meshingparameter_description.c_str(),
py::call_guard<py::gil_scoped_release>())
meshingparameter_description.c_str())
.def ("OptimizeVolumeMesh", [](Mesh & self, MeshingParameters* pars)
{

View File

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