@@ -43,6 +43,7 @@ PythonSystemLoader::~PythonSystemLoader()
43
43
{
44
44
if (this ->pythonSystem )
45
45
{
46
+ py::gil_scoped_acquire gil;
46
47
if (py::hasattr (this ->pythonSystem , " shutdown" ))
47
48
{
48
49
this ->pythonSystem .attr (" shutdown" )();
@@ -54,6 +55,7 @@ void PythonSystemLoader::Configure(
54
55
const Entity &_entity, const std::shared_ptr<const sdf::Element> &_sdf,
55
56
EntityComponentManager &_ecm, EventManager &_eventMgr)
56
57
{
58
+ py::gil_scoped_acquire gil;
57
59
auto [moduleName, hasModule] = _sdf->Get <std::string>(" module_name" , " " );
58
60
if (!hasModule)
59
61
{
@@ -199,7 +201,6 @@ void PythonSystemLoader::PreUpdate(const UpdateInfo &_info,
199
201
// from the PythonSystem code
200
202
py::gil_scoped_acquire gil;
201
203
CallPythonMethod (this ->preUpdateMethod , _info, &_ecm);
202
- py::gil_scoped_release gilr;
203
204
}
204
205
205
206
// ////////////////////////////////////////////////
@@ -208,7 +209,6 @@ void PythonSystemLoader::Update(const UpdateInfo &_info,
208
209
{
209
210
py::gil_scoped_acquire gil;
210
211
CallPythonMethod (this ->updateMethod , _info, &_ecm);
211
- py::gil_scoped_release gilr;
212
212
}
213
213
214
214
// ////////////////////////////////////////////////
@@ -217,12 +217,12 @@ void PythonSystemLoader::PostUpdate(const UpdateInfo &_info,
217
217
{
218
218
py::gil_scoped_acquire gil;
219
219
CallPythonMethod (this ->postUpdateMethod , _info, &_ecm);
220
- py::gil_scoped_release gilr;
221
220
}
222
221
// ////////////////////////////////////////////////
223
222
void PythonSystemLoader::Reset (const UpdateInfo &_info,
224
223
EntityComponentManager &_ecm)
225
224
{
225
+ py::gil_scoped_acquire gil;
226
226
CallPythonMethod (this ->resetMethod , _info, &_ecm);
227
227
}
228
228
0 commit comments