Prevent crash if python code is executed in a rocksdb background thread

This commit is contained in:
hofmockel 2014-01-19 12:35:36 +01:00
parent ecb6e26546
commit 0d20a2564a

View file

@ -35,6 +35,13 @@ import errors
cdef extern from "cpp/utils.hpp" namespace "py_rocks": cdef extern from "cpp/utils.hpp" namespace "py_rocks":
cdef const Slice* vector_data(vector[Slice]&) cdef const Slice* vector_data(vector[Slice]&)
# Prepare python for threaded usage.
# Python callbacks (merge, comparator)
# could be executed in a rocksdb background thread (eg. compaction).
cdef extern from "Python.h":
void PyEval_InitThreads()
PyEval_InitThreads()
## Here comes the stuff to wrap the status to exception ## Here comes the stuff to wrap the status to exception
cdef check_status(const Status& st): cdef check_status(const Status& st):
if st.ok(): if st.ok():