Skip to content

Commit 34803ce

Browse files
committed
Acquiring GIL in pywrapper.cpp
1 parent 4c73dc4 commit 34803ce

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: symengine/lib/pywrapper.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
namespace SymEngine {
99

10+
#if PY_MAJOR_VERSION >= 3
11+
if (!PyGILState_Check()) {
12+
PyEval_AcquireLock();
13+
}
14+
#endif
15+
1016
// PyModule
1117
PyModule::PyModule(PyObject* (*to_py)(const RCP<const Basic>), RCP<const Basic> (*from_py)(PyObject*),
1218
RCP<const Number> (*eval)(PyObject*, long), RCP<const Basic> (*diff)(PyObject*, RCP<const Basic>)) :
@@ -274,4 +280,10 @@ int PyFunction::compare(const Basic &o) const {
274280
return unified_compare(arg_, s.arg_);
275281
}
276282

283+
#if PY_MAJOR_VERSION >= 3
284+
if (PyGILState_Check()) {
285+
PyEval_ReleaseLock();
286+
}
287+
#endif
288+
277289
} // SymEngine

0 commit comments

Comments
 (0)