Update _rocksdb.pyx

This commit is contained in:
iFA 2021-03-11 18:19:40 +01:00 committed by GitHub
parent a846ec9af5
commit 92b8097048
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -159,6 +159,7 @@ cdef class PyGenericComparator(PyComparator):
def __dealloc__(self): def __dealloc__(self):
if not self.comparator_ptr == NULL: if not self.comparator_ptr == NULL:
with nogil:
del self.comparator_ptr del self.comparator_ptr
cdef object get_ob(self): cdef object get_ob(self):
@ -771,6 +772,7 @@ cdef class _ColumnFamilyHandle:
def __dealloc__(self): def __dealloc__(self):
if not self.handle == NULL: if not self.handle == NULL:
with nogil:
del self.handle del self.handle
@staticmethod @staticmethod
@ -879,6 +881,7 @@ cdef class ColumnFamilyOptions(object):
def __dealloc__(self): def __dealloc__(self):
if not self.copts == NULL: if not self.copts == NULL:
with nogil:
del self.copts del self.copts
def __init__(self, **kwargs): def __init__(self, **kwargs):
@ -1290,7 +1293,8 @@ cdef class Options(ColumnFamilyOptions):
def __dealloc__(self): def __dealloc__(self):
if not self.opts == NULL: if not self.opts == NULL:
self.copts = NULL with nogil:
del self.copts
del self.opts del self.opts
def __init__(self, **kwargs): def __init__(self, **kwargs):
@ -1545,6 +1549,7 @@ cdef class WriteBatch(object):
def __dealloc__(self): def __dealloc__(self):
if not self.batch == NULL: if not self.batch == NULL:
with nogil:
del self.batch del self.batch
def put(self, key, value): def put(self, key, value):
@ -1753,13 +1758,13 @@ cdef class DB(object):
db.CancelAllBackgroundWork(self.db, c_safe) db.CancelAllBackgroundWork(self.db, c_safe)
# We have to make sure we delete the handles so rocksdb doesn't # We have to make sure we delete the handles so rocksdb doesn't
# assert when we delete the db # assert when we delete the db
del self.cf_handles[:] self.cf_handles.clear()
for copts in self.cf_options: for copts in self.cf_options:
if copts: if copts:
copts.in_use = False copts.in_use = False
del self.cf_options[:] self.cf_options.clear()
with nogil: with nogil:
st = self.db.Close() self.db.Close()
self.db = NULL self.db = NULL
if self.opts is not None: if self.opts is not None:
self.opts.in_use = False self.opts.in_use = False
@ -2299,6 +2304,7 @@ cdef class BaseIterator(object):
def __dealloc__(self): def __dealloc__(self):
if not self.ptr == NULL: if not self.ptr == NULL:
with nogil:
del self.ptr del self.ptr
def __iter__(self): def __iter__(self):