Skip to content

Commit

Permalink
Call PyEval_InitThreads() when constructing a callback comparator
Browse files Browse the repository at this point in the history
LevelDB uses a background thread for compaction, and with custom
comparators this background thread calls back into Python code, which
means the GIL must be initialized.

Fixes #35.
  • Loading branch information
wbolster committed Aug 26, 2014
1 parent cc6c4f1 commit 635777d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plyvel/comparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class PlyvelCallbackComparator : public leveldb::Comparator
{
Py_INCREF(comparator);
zero = PyLong_FromLong(0);

/* LevelDB uses a background thread for compaction, and with custom
* comparators this background thread calls back into Python code,
* which means the GIL must be initialized. */
PyEval_InitThreads();
}

~PlyvelCallbackComparator()
Expand Down

0 comments on commit 635777d

Please sign in to comment.