diff --git a/README.md b/README.md index c223cd2..2ba4bb0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Non-Metric Space Library (NMSLIB) ================= -The latest **pre**-release is [1.7](https://github.com/searchivarius/nmslib/releases/tag/v1.7). Note that the manual is not updated to reflect some of the changes. In particular, we changed the build procedure for Windows. Also note that the manual targets primiarily developers who will extend the library. For most other folks, [Python binding docs should be sufficient](python_bindings). +The latest **pre**-release is [1.7.1](https://github.com/searchivarius/nmslib/releases/tag/v1.7.1). Note that the manual is not updated to reflect some of the changes. In particular, we changed the build procedure for Windows. Also note that the manual targets primiarily developers who will extend the library. For most other folks, [Python binding docs should be sufficient](python_bindings). ----------------- Non-Metric Space Library (NMSLIB) is an **efficient** cross-platform similarity search library and a toolkit for evaluation of similarity search methods. The core-library does **not** have any third-party dependencies. diff --git a/python_bindings/nmslib.cc b/python_bindings/nmslib.cc index 6bc86ca..764de97 100644 --- a/python_bindings/nmslib.cc +++ b/python_bindings/nmslib.cc @@ -74,12 +74,12 @@ struct IndexWrapper { loadParams(space_params))) { auto vectSpacePtr = dynamic_cast*>(space.get()); if (data_type == DATATYPE_DENSE_VECTOR && vectSpacePtr == nullptr) { - throw std::invalid_argument("The space type " + space_type + + throw std::invalid_argument("The space type " + space_type + " is not compatible with the type DENSE_VECTOR, only dense vector spaces are allowed!"); } auto vectSiftPtr = dynamic_cast(space.get()); if (data_type == DATATYPE_DENSE_UINT8_VECTOR && vectSiftPtr == nullptr) { - throw std::invalid_argument("The space type " + space_type + + throw std::invalid_argument("The space type " + space_type + " is not compatible with the type DENSE_UINT8_VECTOR!"); } } @@ -361,6 +361,20 @@ struct IndexWrapper { ObjectVector data; }; +// pybind11::gil_scoped_acquire can deadlock when acquiring the GIL on threads +// created from python (https://github.com/searchivarius/nmslib/issues/291) +// This might be fixed in a future version of pybind11 (https://github.com/pybind/pybind11/pull/1211) +// but until then, lets fall back to the python c-api to fix. +struct AcquireGIL { + PyGILState_STATE state; + AcquireGIL() + : state(PyGILState_Ensure()) { + } + ~AcquireGIL() { + PyGILState_Release(state); + } +}; + class PythonLogger : public Logger { public: @@ -374,7 +388,7 @@ class PythonLogger int line, const char * function, const std::string & message) { - py::gil_scoped_acquire l; + AcquireGIL l; switch(severity) { case LIB_DEBUG: inner.attr("debug")(message);