@@ -77,7 +77,7 @@ struct PythonObjectVisitor : boost::static_visitor<py::object>
7777struct ValueVisitor : boost::static_visitor<Variable::Value>
7878{
7979private:
80- const py::object& object_;
80+ py::object object_;
8181public:
8282 explicit ValueVisitor (const py::object& object) : object_(object) {}
8383
@@ -132,10 +132,12 @@ struct ValueVisitor : boost::static_visitor<Variable::Value>
132132 const auto firstVal = v[0 ];
133133 const py::extract<py::list> e (object_);
134134 auto pyList = e ();
135+ auto gil = PyGILState_Ensure ();
135136 Variable::List newList (py::len (pyList));
136137 for (auto i = 0 ; i < py::len (pyList); ++i)
137138 newList[i] = Variable (firstVal.name (),
138139 boost::apply_visitor (ValueVisitor (pyList[i]), firstVal.value ()));
140+ PyGILState_Release (gil);
139141 return newList;
140142 }
141143 else
@@ -626,7 +628,10 @@ Variable SCIRun::Core::Python::convertPythonObjectToVariable(const py::object& o
626628Variable SCIRun::Core::Python::convertPythonObjectToVariableWithTypeInference (
627629 const py::object& object, const Variable& var)
628630{
629- return Variable (var.name (), boost::apply_visitor (ValueVisitor (object), var.value ()));
631+ auto gil = PyGILState_Ensure ();
632+ Variable result (var.name (), boost::apply_visitor (ValueVisitor (object), var.value ()));
633+ PyGILState_Release (gil);
634+ return result;
630635}
631636
632637py::object SCIRun::Core::Python::convertVariableToPythonObject (const Variable& var)
0 commit comments