From 43a6997362c4ad59582d01d24a69308aefcd3579 Mon Sep 17 00:00:00 2001 From: hofmockel Date: Fri, 24 Jan 2014 17:03:14 +0100 Subject: [PATCH] Fix deadlock on shutdown by releasing the GIL during del On delete rocksdb waits for the background thread to finish. However the background threads needs the GIL to execute python-code (for example comparator) => * main thread has GIL * main thread waits for background thread * background thread tries to get GIL which means deadlock --- rocksdb/_rocksdb.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rocksdb/_rocksdb.pyx b/rocksdb/_rocksdb.pyx index 1af70b1..9106f05 100644 --- a/rocksdb/_rocksdb.pyx +++ b/rocksdb/_rocksdb.pyx @@ -1095,7 +1095,9 @@ cdef class DB(object): def __dealloc__(self): if not self.db == NULL: - del self.db + with nogil: + del self.db + if self.opts is not None: self.opts.in_use = False