acquire GIL before updating python path

This commit is contained in:
Axel Kohlmeyer
2021-03-06 14:40:18 -05:00
parent 08a25af1c9
commit 1220aa2eff

View File

@ -49,14 +49,19 @@ PairPython::PairPython(LAMMPS *lmp) : Pair(lmp) {
python->init();
// add current directory to PYTHONPATH
PyObject * py_path = PySys_GetObject((char *)"path");
PyGILState_STATE gstate = PyGILState_Ensure();
PyObject *py_path = PySys_GetObject((char *)"path");
PyList_Append(py_path, PY_STRING_FROM_STRING("."));
// if LAMMPS_POTENTIALS environment variable is set, add it to PYTHONPATH as well
const char * potentials_path = getenv("LAMMPS_POTENTIALS");
// if LAMMPS_POTENTIALS environment variable is set,
// add it to PYTHONPATH as well
const char *potentials_path = getenv("LAMMPS_POTENTIALS");
if (potentials_path != nullptr) {
PyList_Append(py_path, PY_STRING_FROM_STRING(potentials_path));
}
PyGILState_Release(gstate);
}
/* ---------------------------------------------------------------------- */