Open alekibango opened 9 years ago
Hi, in general it would be possible to close the db by doing
del self.db
self.db = NULL
However, then all the other calls like 'put, delete, get, ......' must have a check for
if self.db == NULL:
raise Exception("DB is closed")
Also all iterators and snapshots are invalid, which means they need also a check if their according DB is still valid.
I'm not sure if a 'close()' method justifies these many checks + complicating the code. If I would not do such checks, the program will just fail with a 'SEGFAULT', because the database pointer is not valid any more. From my point of view a 'close()' method should not lead to SEGFAULT if not used correctly. Instead I would expect proper exceptions like 'DB is closed'.
So for now I'm very reluctant to add this feature, but I'll keep this ticket open, so that other users of this wrapper could post their opinion here. If I see that many users need this function I'm going to add it.
I think this item can be closed - though it's a good documentation note.
@stephan-hof thanks for explanation here and in my other similar issues too. it really helped, even if i didnt get what i asked for :)
Imho closing DB maybe should be part of python api.