Skip to content

Commit

Permalink
KnobHelper::executeExpression: remove spurious PythonGILLocker
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Jan 15, 2022
1 parent c67ec07 commit b3e0c62
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Engine/Knob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3058,6 +3058,8 @@ catchErrors(PyObject* mainModule,
return true;
}

///The return value must be Py_DECRREF
/// The Python GIL must be held before calling this, so the the PyObject remains valid.
bool
KnobHelper::executeExpression(double time,
ViewIdx view,
Expand All @@ -3078,12 +3080,17 @@ KnobHelper::executeExpression(double time,
}


/// The return value must be Py_DECRREF
/// The expression must put its result in the Python variable named "ret"
/// The Python GIL must be held before calling this, so the the PyObject remains valid.
bool
KnobHelper::executeExpression(const std::string& expr,
PyObject** ret,
std::string* error)
{
PythonGILLocker pgl;
#if PY_VERSION_HEX >= 0x030400F0
assert(PyGILState_Check()); // Not available prior to Python 3.4
#endif

//returns a new ref, this function's documentation is not clear onto what it returns...
//https://docs.python.org/2/c-api/veryhigh.html
Expand Down
2 changes: 2 additions & 0 deletions Engine/Knob.h
Original file line number Diff line number Diff line change
Expand Up @@ -1631,12 +1631,14 @@ class KnobHelper
void resetMaster(int dimension);

///The return value must be Py_DECRREF
/// The Python GIL must be held before calling this, so the the PyObject remains valid.
bool executeExpression(double time, ViewIdx view, int dimension, PyObject** ret, std::string* error) const;

public:

/// The return value must be Py_DECRREF
/// The expression must put its result in the Python variable named "ret"
/// The Python GIL must be held before calling this, so the the PyObject remains valid.
static bool executeExpression(const std::string& expr, PyObject** ret, std::string* error);

virtual std::pair<int, KnobIPtr> getMaster(int dimension) const OVERRIDE FINAL WARN_UNUSED_RETURN;
Expand Down

0 comments on commit b3e0c62

Please sign in to comment.