Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method to close db? #32

Open
alekibango opened this issue Jul 31, 2015 · 3 comments
Open

method to close db? #32

alekibango opened this issue Jul 31, 2015 · 3 comments

Comments

@alekibango
Copy link

Imho closing DB maybe should be part of python api.

    def _close_db(self):
        del self.db
        gc.collect()
@stephan-hof
Copy link
Owner

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.

@Downchuck
Copy link

I think this item can be closed - though it's a good documentation note.

@alekibango
Copy link
Author

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants