Unverified Commit 446aaeb4 authored by Raimondas Galvelis's avatar Raimondas Galvelis Committed by GitHub
Browse files

Fix GIL for OpenMM::Context::setVelocitiesToTemperature (#3424)

parent 7d0ec0bc
...@@ -51,3 +51,17 @@ ...@@ -51,3 +51,17 @@
} }
PyEval_RestoreThread(_savePythonThreadState); PyEval_RestoreThread(_savePythonThreadState);
} }
%exception OpenMM::Context::setVelocitiesToTemperature {
PyThreadState* _savePythonThreadState = PyEval_SaveThread();
try {
$action
} catch (std::exception &e) {
PyEval_RestoreThread(_savePythonThreadState);
PyObject* mm = PyImport_AddModule("openmm");
PyObject* openmm_exception = PyObject_GetAttrString(mm, "OpenMMException");
PyErr_SetString(openmm_exception, const_cast<char*>(e.what()));
return NULL;
}
PyEval_RestoreThread(_savePythonThreadState);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment