From a191e7e2a136b20ec94154a199bef179cc426c15 Mon Sep 17 00:00:00 2001
From: iFA <ifa@fusionsolutions.io>
Date: Sun, 17 Jan 2021 16:09:26 +0100
Subject: [PATCH] Fixing closing

---
 rocksdb/_rocksdb.pyx | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/rocksdb/_rocksdb.pyx b/rocksdb/_rocksdb.pyx
index 46e0d66..4d8cf41 100644
--- a/rocksdb/_rocksdb.pyx
+++ b/rocksdb/_rocksdb.pyx
@@ -1729,13 +1729,11 @@ cdef class DB(object):
         self.opts = opts
         self.opts.in_use = True
 
-    def __dealloc__(self):
-        self.close()
-
     def close(self, safe=True):
         cdef ColumnFamilyOptions copts
         cdef cpp_bool c_safe = safe
-        if hasattr(self, "db"):
+        cdef Status st
+        if self.db != NULL:
             # We need stop backround compactions
             with nogil:
                 db.CancelAllBackgroundWork(self.db, c_safe)
@@ -1746,15 +1744,14 @@ cdef class DB(object):
                 if copts:
                     copts.in_use = False
             del self.cf_options[:]
-
             with nogil:
                 st = self.db.Close()
-                del self.db
-
+                self.db = NULL
             if self.opts is not None:
                 self.opts.in_use = False
 
-            check_status(st)
+    def __dealloc__(self):
+        self.close()
 
     @property
     def column_families(self):
-- 
GitLab